diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2005-03-23 04:14:46 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2005-03-23 04:14:46 +0000 |
commit | 81e1b023da77edb3576be645e73332a03407346c (patch) | |
tree | b42b489d2b926754e85a31a187d72b3290975897 /ld | |
parent | 1ec0126d51dac1afdf19ef609cf1b35864d73247 (diff) | |
download | gdb-81e1b023da77edb3576be645e73332a03407346c.zip gdb-81e1b023da77edb3576be645e73332a03407346c.tar.gz gdb-81e1b023da77edb3576be645e73332a03407346c.tar.bz2 |
bfd/
2005-03-22 H.J. Lu <hongjiu.lu@intel.com>
* bfd-in.h (_bfd_elf_provide_symbol): New.
* bfd-in2.h: Regenerated.
* elf32-ppc.c (set_linker_sym): Moved to elflink.c.
(ppc_elf_set_sdata_syms): Call _bfd_elf_provide_symbol instead
of set_linker_sym.
* elflink.c (_bfd_elf_provide_symbol): New. Moved and renamed
from elf32-ppc.c.
ld/
2005-03-22 H.J. Lu <hongjiu.lu@intel.com>
* emultempl/elf32.em (gld${EMULATION_NAME}_provide_bound_symbols): New
(gld${EMULATION_NAME}_finish): Call
gld${EMULATION_NAME}_provide_bound_symbols to provide
__preinit_array_start, __preinit_array_end, __init_array_start,
__init_array_end, __fini_array_start and __fini_array_end.
* scripttempl/elf.sc: Don't provide __preinit_array_start,
__preinit_array_end, __init_array_start, __init_array_end,
__fini_array_start nor __fini_array_end.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 12 | ||||
-rw-r--r-- | ld/emultempl/elf32.em | 51 | ||||
-rw-r--r-- | ld/scripttempl/elf.sc | 13 |
3 files changed, 63 insertions, 13 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 1378cb5..49e0a0c 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,15 @@ +2005-03-22 H.J. Lu <hongjiu.lu@intel.com> + + * emultempl/elf32.em (gld${EMULATION_NAME}_provide_bound_symbols): New + (gld${EMULATION_NAME}_finish): Call + gld${EMULATION_NAME}_provide_bound_symbols to provide + __preinit_array_start, __preinit_array_end, __init_array_start, + __init_array_end, __fini_array_start and __fini_array_end. + + * scripttempl/elf.sc: Don't provide __preinit_array_start, + __preinit_array_end, __init_array_start, __init_array_end, + __fini_array_start nor __fini_array_end. + 2005-03-23 Alan Modra <amodra@bigpond.net.au> * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Set diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 00805d5..b2d2a7c 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1428,6 +1428,29 @@ if test x"$LDEMUL_FINISH" != xgld"$EMULATION_NAME"_finish; then cat >>e${EMULATION_NAME}.c <<EOF static void +gld${EMULATION_NAME}_provide_bound_symbols (const char *sec, + const char *start, + const char *end) +{ + asection *s; + bfd_vma start_val, end_val; + + s = bfd_get_section_by_name (output_bfd, sec); + if (s != NULL) + { + start_val = s->vma; + end_val = start_val + s->size; + } + else + { + start_val = 0; + end_val = 0; + } + _bfd_elf_provide_symbol (&link_info, start, start_val); + _bfd_elf_provide_symbol (&link_info, end, end_val); +} + +static void gld${EMULATION_NAME}_finish (void) { if (bfd_elf_discard_info (output_bfd, &link_info)) @@ -1472,6 +1495,34 @@ gld${EMULATION_NAME}_finish (void) } } } + + /* If not building shared library, provide + + __preinit_array_start + __preinit_array_end + __init_array_start + __init_array_end + __fini_array_start + __fini_array_end + + They are set here rather than via PROVIDE in the linker + script, because using PROVIDE inside an output section + statement results in unnecessary output sections. Using + PROVIDE outside an output section statement runs the risk of + section alignment affecting where the section starts. */ + + if (!link_info.shared) + { + gld${EMULATION_NAME}_provide_bound_symbols + (".preinit_array", "__preinit_array_start", + "__preinit_array_end"); + gld${EMULATION_NAME}_provide_bound_symbols + (".init_array", "__init_array_start", + "__init_array_end"); + gld${EMULATION_NAME}_provide_bound_symbols + (".fini_array", "__fini_array_start", + "__fini_array_end"); + } } } EOF diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index 4ff6467..a6c0a63 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -333,22 +333,9 @@ cat <<EOF .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } - /* Ensure the __preinit_array_start label is properly aligned. We - could instead move the label definition inside the section, but - the linker would then create the section even if it turns out to - be empty, which isn't pretty. */ - ${RELOCATING+. = ALIGN(${ALIGNMENT});} - ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}} .preinit_array ${RELOCATING-0} : { KEEP (*(.preinit_array)) } - ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}} - - ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_start = .);}} .init_array ${RELOCATING-0} : { KEEP (*(.init_array)) } - ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_end = .);}} - - ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_start = .);}} .fini_array ${RELOCATING-0} : { KEEP (*(.fini_array)) } - ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}} ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} |