diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-26 15:53:51 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-26 15:53:51 +0000 |
commit | 6c181a06910945b84fbe73a7cd4415542bec4867 (patch) | |
tree | bc456dae4427f9afc91988189cd6ee26800382a0 /gcc/varasm.c | |
parent | d4c1506135aa7e2264bfede7cba0f3fcfaf1972a (diff) | |
download | gcc-6c181a06910945b84fbe73a7cd4415542bec4867.tar.gz |
* output.h (assemble_addr_to_section): Declare.
(get_cdtor_priority_section): Likewise.
* varasm.c (assemble_addr_to_section): New function.
(get_cdtor_priority_section): Likewise.
(default_named_section_asm_out_destructor): Use them.
(destor_dtor_section_asm_out_destructor): Likewise.
(default_named_section_asm_out_constructor): Likewise.
(default_ctor_section_asm_out_constructor): Likewise.
* config.gcc (*-*-vxworks*): Include vxworks.o.
* config/t-vxworks (vxworks.o): New target.
* config/vxworks.h (ALWAYS_NUMBER_CTORS_SECTIONS): Remove.
(TARGET_ASM_CONSTRUCTOR): Define.
(TARGET_ASM_DESTRUCTOR): Likewise.
(vxworks_asm_out_constructor): Declare.
(vxworks_asm_out_destructor): Likewise.
* c-common.c (get_priority): Check that we have not just an
INTEGER_CST, but an integer constant with integeral type.
* gcc.dg/vxworks/vxworks.exp: New file.
* gcc.dg/vxworks/initpri1.c: Likewise.
* gcc.dg/vxworks/initpri2.c: Likewise.
* gcc.dg/initpri2.c: Add more tests.
* g++.dg/special/initpri2.C: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122335 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index 6c221459285..c92a5a08f42 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1448,26 +1448,44 @@ default_stabs_asm_out_destructor (rtx symbol ATTRIBUTE_UNUSED, #endif } -void -default_named_section_asm_out_destructor (rtx symbol, int priority) +/* Write the address of the entity given by SYMBOL to SEC. */ +void +assemble_addr_to_section (rtx symbol, section *sec) +{ + switch_to_section (sec); + assemble_align (POINTER_SIZE); + assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); +} + +/* Return the numbered .ctors.N (if CONSTRUCTOR_P) or .dtors.N (if + not) section for PRIORITY. */ +section * +get_cdtor_priority_section (int priority, bool constructor_p) { - const char *section = ".dtors"; char buf[16]; /* ??? This only works reliably with the GNU linker. */ + sprintf (buf, "%s.%.5u", + constructor_p ? ".ctors" : ".dtors", + /* Invert the numbering so the linker puts us in the proper + order; constructors are run from right to left, and the + linker sorts in increasing order. */ + MAX_INIT_PRIORITY - priority); + return get_section (buf, SECTION_WRITE, NULL); +} + +void +default_named_section_asm_out_destructor (rtx symbol, int priority) +{ + section *sec; + if (priority != DEFAULT_INIT_PRIORITY) - { - sprintf (buf, ".dtors.%.5u", - /* Invert the numbering so the linker puts us in the proper - order; constructors are run from right to left, and the - linker sorts in increasing order. */ - MAX_INIT_PRIORITY - priority); - section = buf; - } + sec = get_cdtor_priority_section (priority, + /*constructor_p=*/false); + else + sec = get_section (".dtors", SECTION_WRITE, NULL); - switch_to_section (get_section (section, SECTION_WRITE, NULL)); - assemble_align (POINTER_SIZE); - assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); + assemble_addr_to_section (symbol, sec); } #ifdef DTORS_SECTION_ASM_OP @@ -1475,9 +1493,7 @@ void default_dtor_section_asm_out_destructor (rtx symbol, int priority ATTRIBUTE_UNUSED) { - switch_to_section (dtors_section); - assemble_align (POINTER_SIZE); - assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); + assemble_addr_to_section (symbol, dtors_section); } #endif @@ -1501,23 +1517,15 @@ default_stabs_asm_out_constructor (rtx symbol ATTRIBUTE_UNUSED, void default_named_section_asm_out_constructor (rtx symbol, int priority) { - const char *section = ".ctors"; - char buf[16]; + section *sec; - /* ??? This only works reliably with the GNU linker. */ if (priority != DEFAULT_INIT_PRIORITY) - { - sprintf (buf, ".ctors.%.5u", - /* Invert the numbering so the linker puts us in the proper - order; constructors are run from right to left, and the - linker sorts in increasing order. */ - MAX_INIT_PRIORITY - priority); - section = buf; - } + sec = get_cdtor_priority_section (priority, + /*constructor_p=*/true); + else + sec = get_section (".ctors", SECTION_WRITE, NULL); - switch_to_section (get_section (section, SECTION_WRITE, NULL)); - assemble_align (POINTER_SIZE); - assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); + assemble_addr_to_section (symbol, sec); } #ifdef CTORS_SECTION_ASM_OP @@ -1525,9 +1533,7 @@ void default_ctor_section_asm_out_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED) { - switch_to_section (ctors_section); - assemble_align (POINTER_SIZE); - assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); + assemble_addr_to_section (symbol, ctors_section); } #endif |