Commit d9f6800d by Richard Henderson Committed by Richard Henderson

rs6000.c (rs6000_elf_asm_out_constructor): New.

        * config/rs6000/rs6000.c (rs6000_elf_asm_out_constructor): New.
        (rs6000_elf_asm_out_destructor): New.                                           * config/rs6000/sysv4.h (CTORS_SECTION_ASM_OP): Remove.
        (DTORS_SECTION_ASM_OP): Remove.                                                 (TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR): New.
        (ASM_OUTPUT_INT): Don't hack TARGET_RELOCATABLE for constructors.

From-SVN: r44835
parent 6ba57472
2001-08-12 Richard Henderson <rth@redhat.com>
* config/rs6000/rs6000.c (rs6000_elf_asm_out_constructor): New.
(rs6000_elf_asm_out_destructor): New.
* config/rs6000/sysv4.h (CTORS_SECTION_ASM_OP): Remove.
(DTORS_SECTION_ASM_OP): Remove.
(TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR): New.
(ASM_OUTPUT_INT): Don't hack TARGET_RELOCATABLE for constructors.
2001-08-12 David Edelsohn <edelsohn@gnu.org> 2001-08-12 David Edelsohn <edelsohn@gnu.org>
Revert: Revert:
......
...@@ -134,6 +134,8 @@ static rtx rs6000_emit_set_long_const PARAMS ((rtx, ...@@ -134,6 +134,8 @@ static rtx rs6000_emit_set_long_const PARAMS ((rtx,
#if TARGET_ELF #if TARGET_ELF
static unsigned int rs6000_elf_section_type_flags PARAMS ((tree, const char *, static unsigned int rs6000_elf_section_type_flags PARAMS ((tree, const char *,
int)); int));
static void rs6000_elf_asm_out_constructor PARAMS ((rtx, int));
static void rs6000_elf_asm_out_destructor PARAMS ((rtx, int));
#endif #endif
#ifdef OBJECT_FORMAT_COFF #ifdef OBJECT_FORMAT_COFF
static void xcoff_asm_named_section PARAMS ((const char *, unsigned int, static void xcoff_asm_named_section PARAMS ((const char *, unsigned int,
...@@ -8707,6 +8709,73 @@ rs6000_elf_section_type_flags (decl, name, reloc) ...@@ -8707,6 +8709,73 @@ rs6000_elf_section_type_flags (decl, name, reloc)
return flags; return flags;
} }
/* Record an element in the table of global constructors. SYMBOL is
a SYMBOL_REF of the function to be called; PRIORITY is a number
between 0 and MAX_INIT_PRIORITY.
This differs from default_named_section_asm_out_constructor in
that we have special handling for -mrelocatable. */
static void
rs6000_elf_asm_out_constructor (symbol, priority)
rtx symbol;
int priority;
{
const char *section = ".ctors";
char buf[16];
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;
}
named_section_flags (section, SECTION_WRITE, POINTER_SIZE / BITS_PER_UNIT);
if (TARGET_RELOCATABLE)
{
fputs ("\t.long (", asm_out_file);
output_addr_const (asm_out_file, symbol);
fputs (")@fixup\n", asm_out_file);
}
else
assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
}
static void
rs6000_elf_asm_out_destructor (symbol, priority)
rtx symbol;
int priority;
{
const char *section = ".dtors";
char buf[16];
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;
}
named_section_flags (section, SECTION_WRITE, POINTER_SIZE / BITS_PER_UNIT);
if (TARGET_RELOCATABLE)
{
fputs ("\t.long (", asm_out_file);
output_addr_const (asm_out_file, symbol);
fputs (")@fixup\n", asm_out_file);
}
else
assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
}
#endif #endif
#ifdef OBJECT_FORMAT_COFF #ifdef OBJECT_FORMAT_COFF
......
...@@ -555,13 +555,6 @@ fini_section () \ ...@@ -555,13 +555,6 @@ fini_section () \
} \ } \
} }
/* Ordinarily, we wouldn't need to define these, since generic code would
do the right thing based on knowing that we have named sections.
However, -mrelocatable needs to know when we're in [cd]tors sections,
and the easiest way to do that is rely on varasm.c defining in_[cd]tors. */
#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
/* A C statement or statements to switch to the appropriate section /* A C statement or statements to switch to the appropriate section
for output of RTX in mode MODE. You can assume that RTX is some for output of RTX in mode MODE. You can assume that RTX is some
kind of constant in RTL. The argument MODE is redundant except in kind of constant in RTL. The argument MODE is redundant except in
...@@ -816,6 +809,10 @@ do { \ ...@@ -816,6 +809,10 @@ do { \
extern int fixuplabelno; extern int fixuplabelno;
/* Handle constructors specially for -mrelocatable. */
#define TARGET_ASM_CONSTRUCTOR rs6000_elf_asm_out_constructor
#define TARGET_ASM_DESTRUCTOR rs6000_elf_asm_out_destructor
/* This is how to output an assembler line defining an `int' constant. /* This is how to output an assembler line defining an `int' constant.
For -mrelocatable, we mark all addresses that need to be fixed up For -mrelocatable, we mark all addresses that need to be fixed up
in the .fixup section. */ in the .fixup section. */
...@@ -827,8 +824,6 @@ do { \ ...@@ -827,8 +824,6 @@ do { \
if (TARGET_RELOCATABLE \ if (TARGET_RELOCATABLE \
&& in_section != in_toc \ && in_section != in_toc \
&& in_section != in_text \ && in_section != in_text \
&& in_section != in_ctors \
&& in_section != in_dtors \
&& !recurse \ && !recurse \
&& GET_CODE (VALUE) != CONST_INT \ && GET_CODE (VALUE) != CONST_INT \
&& GET_CODE (VALUE) != CONST_DOUBLE \ && GET_CODE (VALUE) != CONST_DOUBLE \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment