diff options
author | jules <jules@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-29 14:09:45 +0000 |
---|---|---|
committer | jules <jules@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-29 14:09:45 +0000 |
commit | d24bc14583aaf3a0edb93267bffb5b240252d87c (patch) | |
tree | a069a1c7e66dac7e1d042f7a22530125e2918422 /gcc/config/arm | |
parent | c828481ae6866cf54f3fe408e82e81d93c38b6d6 (diff) | |
download | gcc-d24bc14583aaf3a0edb93267bffb5b240252d87c.tar.gz |
* crtstuff.c: Handle targets that use .init_array.
* function.c (HAS_INIT_SECTION): Do not define. Instead, make sure
that INVOKE__main is set correctly.
(expand_main_function): Test INVOKE__main.
* libgcc2.c: Do not define __main when using .init_array.
* config/arm/arm.c (arm_elf_asm_constructor): New function.
* config/arm/arm.h (CTORS_SECTION_ASM_OP): Define, with specialized
libgcc version.
(DTORS_SECTION_ASM_OP): Likewise.
(CTOR_LIST_BEGIN): Define specially when in libgcc.
(CTOR_LIST_END): Likewise.
(DTOR_LIST_BEGIN): Likewise.
(DTOR_LIST_END): Likewise.
* config/arm/bpapi.h (INIT_SECTION_ASM_OP): Do not define it.
(FINI_SECTION_ASM_OP): Likewise.
(INIT_ARRAY_SECTION_ASM_OP): Define.
(FINI_ARRAY_SECTION_ASM_OP): Likewise.
* config/arm/elf.h (TARGET_ASM_CONSTRUCTOR): Define.
(SUPPORTS_INIT_PRIORITY): Evaluate to false for EABI based targets.
* doc/tm.texi (INIT_ARRAY_SECTION_ASM_OP): Document.
(FINI_ARRAY_SECTION_ASM_OP): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98986 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/arm')
-rw-r--r-- | gcc/config/arm/arm.c | 23 | ||||
-rw-r--r-- | gcc/config/arm/arm.h | 42 | ||||
-rw-r--r-- | gcc/config/arm/bpabi.h | 7 | ||||
-rw-r--r-- | gcc/config/arm/elf.h | 7 |
4 files changed, 78 insertions, 1 deletions
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index da3b74fc77b..6c0b896ec23 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -144,6 +144,9 @@ static void emit_constant_insn (rtx cond, rtx pattern); static int arm_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode, tree, bool); +#ifdef OBJECT_FORMAT_ELF +static void arm_elf_asm_constructor (rtx, int); +#endif #ifndef ARM_PE static void arm_encode_section_info (tree, rtx, int); #endif @@ -10780,6 +10783,26 @@ arm_assemble_integer (rtx x, unsigned int size, int aligned_p) return default_assemble_integer (x, size, aligned_p); } + + +/* Add a function to the list of static constructors. */ + +static void +arm_elf_asm_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED) +{ + if (!TARGET_AAPCS_BASED) + { + default_named_section_asm_out_constructor (symbol, priority); + return; + } + + /* Put these in the .init_array section, using a special relocation. */ + ctors_section (); + assemble_align (POINTER_SIZE); + fputs ("\t.word\t", asm_out_file); + output_addr_const (asm_out_file, symbol); + fputs ("(target1)\n", asm_out_file); +} #endif /* A finite state machine takes care of noticing whether or not instructions diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index b79e02861b5..4f0eeec6138 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -2122,6 +2122,48 @@ typedef struct #define ASM_OUTPUT_LABELREF(FILE, NAME) \ arm_asm_output_labelref (FILE, NAME) +/* The EABI specifies that constructors should go in .init_array. + Other targets use .ctors for compatibility. */ +#define ARM_EABI_CTORS_SECTION_OP \ + "\t.section\t.init_array,\"aw\",%init_array" +#define ARM_EABI_DTORS_SECTION_OP \ + "\t.section\t.fini_array,\"aw\",%fini_array" +#define ARM_CTORS_SECTION_OP \ + "\t.section\t.ctors,\"aw\",%progbits" +#define ARM_DTORS_SECTION_OP \ + "\t.section\t.dtors,\"aw\",%progbits" + +/* Define CTORS_SECTION_ASM_OP. */ +#undef CTORS_SECTION_ASM_OP +#undef DTORS_SECTION_ASM_OP +#ifndef IN_LIBGCC2 +# define CTORS_SECTION_ASM_OP \ + (TARGET_AAPCS_BASED ? ARM_EABI_CTORS_SECTION_OP : ARM_CTORS_SECTION_OP) +# define DTORS_SECTION_ASM_OP \ + (TARGET_AAPCS_BASED ? ARM_EABI_DTORS_SECTION_OP : ARM_DTORS_SECTION_OP) +#else /* !defined (IN_LIBGCC2) */ +/* In libgcc, CTORS_SECTION_ASM_OP must be a compile-time constant, + so we cannot use the definition above. */ +# ifdef __ARM_EABI__ +/* The .ctors section is not part of the EABI, so we do not define + CTORS_SECTION_ASM_OP when in libgcc; that prevents crtstuff + from trying to use it. We do define it when doing normal + compilation, as .init_array can be used instead of .ctors. */ +/* There is no need to emit begin or end markers when using + init_array; the dynamic linker will compute the size of the + array itself based on special symbols created by the static + linker. However, we do need to arrange to set up + exception-handling here. */ +# define CTOR_LIST_BEGIN asm (ARM_EABI_CTORS_SECTION_OP) +# define CTOR_LIST_END /* empty */ +# define DTOR_LIST_BEGIN asm (ARM_EABI_DTORS_SECTION_OP) +# define DTOR_LIST_END /* empty */ +# else /* !defined (__ARM_EABI__) */ +# define CTORS_SECTION_ASM_OP ARM_CTORS_SECTION_OP +# define DTORS_SECTION_ASM_OP ARM_DTORS_SECTION_OP +# endif /* !defined (__ARM_EABI__) */ +#endif /* !defined (IN_LIBCC2) */ + /* True if the operating system can merge entities with vague linkage (e.g., symbols in COMDAT group) during dynamic linking. */ #ifndef TARGET_ARM_DYNAMIC_VAGUE_LINKAGE_P diff --git a/gcc/config/arm/bpabi.h b/gcc/config/arm/bpabi.h index 6fb11b9838c..037b26de145 100644 --- a/gcc/config/arm/bpabi.h +++ b/gcc/config/arm/bpabi.h @@ -100,3 +100,10 @@ #define TARGET_OS_CPP_BUILTINS() \ TARGET_BPABI_CPP_BUILTINS() + +/* The BPABI specifies the use of .{init,fini}_array. Therefore, we + do not want GCC to put anything into the .{init,fini} sections. */ +#undef INIT_SECTION_ASM_OP +#undef FINI_SECTION_ASM_OP +#define INIT_ARRAY_SECTION_ASM_OP ARM_EABI_CTORS_SECTION_OP +#define FINI_ARRAY_SECTION_ASM_OP ARM_EABI_DTORS_SECTION_OP diff --git a/gcc/config/arm/elf.h b/gcc/config/arm/elf.h index a6c6102d088..9a48a9b30e2 100644 --- a/gcc/config/arm/elf.h +++ b/gcc/config/arm/elf.h @@ -120,6 +120,10 @@ #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true +/* Output an element in the static constructor array. */ +#undef TARGET_ASM_CONSTRUCTOR +#define TARGET_ASM_CONSTRUCTOR arm_elf_asm_constructor + /* For PIC code we need to explicitly specify (PLT) and (GOT) relocs. */ #define NEED_PLT_RELOC flag_pic #define NEED_GOT_RELOC flag_pic @@ -143,4 +147,5 @@ } \ while (0) -#define SUPPORTS_INIT_PRIORITY 1 +/* The EABI doesn't provide a way of implementing init_priority. */ +#define SUPPORTS_INIT_PRIORITY (!TARGET_AAPCS_BASED) |