From 819648a4a9e065999dc9c041715d4af7d727710d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 23 Mar 2005 04:14:43 +0000 Subject: [PATCH] bfd/ 2005-03-22 H.J. Lu * 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 * 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. --- bfd/ChangeLog | 12 ++++++++++++ bfd/bfd-in.h | 3 +++ bfd/bfd-in2.h | 3 +++ bfd/elf32-ppc.c | 30 +++++------------------------- bfd/elflink.c | 21 +++++++++++++++++++++ 5 files changed, 44 insertions(+), 25 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index f02c6775da..3920087608 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,15 @@ +2005-03-22 H.J. Lu + + * 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. + 2005-03-22 Hans-Peter Nilsson * hash.c (strtab_hash_newfunc): Fix typo in allocated size. diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 37c6386632..0222a4e24a 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -694,6 +694,9 @@ extern int bfd_get_sign_extend_vma extern struct bfd_section *_bfd_elf_tls_setup (bfd *, struct bfd_link_info *); +extern void _bfd_elf_provide_symbol + (struct bfd_link_info *, const char *, bfd_vma); + extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **); diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 626e0661b4..131bd83301 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -701,6 +701,9 @@ extern int bfd_get_sign_extend_vma extern struct bfd_section *_bfd_elf_tls_setup (bfd *, struct bfd_link_info *); +extern void _bfd_elf_provide_symbol + (struct bfd_link_info *, const char *, bfd_vma); + extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **); diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 82de7df907..f2a1d38eb2 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -4545,26 +4545,6 @@ ppc_elf_relax_section (bfd *abfd, return FALSE; } -/* Set SYM_NAME to VAL if the symbol exists and is undefined. */ - -static void -set_linker_sym (struct ppc_elf_link_hash_table *htab, - const char *sym_name, - bfd_vma val) -{ - struct elf_link_hash_entry *h; - h = elf_link_hash_lookup (&htab->elf, sym_name, FALSE, FALSE, FALSE); - if (h != NULL && h->root.type == bfd_link_hash_undefined) - { - h->root.type = bfd_link_hash_defined; - h->root.u.def.section = bfd_abs_section_ptr; - h->root.u.def.value = val; - h->def_regular = 1; - h->type = STT_OBJECT; - h->other = STV_HIDDEN; - } -} - /* Set _SDA_BASE_, _SDA2_BASE, and sbss start and end syms. They are set here rather than via PROVIDE in the default linker script, because using PROVIDE inside an output section statement results in @@ -4599,19 +4579,19 @@ ppc_elf_set_sdata_syms (bfd *obfd, struct bfd_link_info *info) val = s->vma + 32768; lsect->sym_val = val; - set_linker_sym (htab, lsect->sym_name, val); + _bfd_elf_provide_symbol (info, lsect->sym_name, val); } s = bfd_get_section_by_name (obfd, ".sbss"); val = 0; if (s != NULL) val = s->vma; - set_linker_sym (htab, "__sbss_start", val); - set_linker_sym (htab, "___sbss_start", val); + _bfd_elf_provide_symbol (info, "__sbss_start", val); + _bfd_elf_provide_symbol (info, "___sbss_start", val); if (s != NULL) val += s->size; - set_linker_sym (htab, "__sbss_end", val); - set_linker_sym (htab, "___sbss_end", val); + _bfd_elf_provide_symbol (info, "__sbss_end", val); + _bfd_elf_provide_symbol (info, "___sbss_end", val); return TRUE; } diff --git a/bfd/elflink.c b/bfd/elflink.c index 783d9b9ea1..9792137d4f 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -9754,3 +9754,24 @@ _bfd_elf_section_already_linked (bfd *abfd, struct bfd_section * sec) /* This is the first section with this name. Record it. */ bfd_section_already_linked_table_insert (already_linked_list, sec); } + +/* Set NAME to VAL if the symbol exists and is undefined. */ + +void +_bfd_elf_provide_symbol (struct bfd_link_info *info, const char *name, + bfd_vma val) +{ + struct elf_link_hash_entry *h; + h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, + FALSE); + if (h != NULL && h->root.type == bfd_link_hash_undefined) + { + h->root.type = bfd_link_hash_defined; + h->root.u.def.section = bfd_abs_section_ptr; + h->root.u.def.value = val; + h->def_regular = 1; + h->type = STT_OBJECT; + h->other = STV_HIDDEN | (h->other & ~ ELF_ST_VISIBILITY (-1)); + h->forced_local = 1; + } +} -- 2.11.0