diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2006-02-24 15:47:25 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2006-02-24 15:47:25 +0000 |
commit | 508c39462ab96fb67c48d04807c999759f5011a0 (patch) | |
tree | 3324af9fed7a793e0506e235ba6b35428c20654f /bfd/elflink.c | |
parent | 62b3e31101ef2dfb96ee4652d5145e722b335e31 (diff) | |
download | gdb-508c39462ab96fb67c48d04807c999759f5011a0.zip gdb-508c39462ab96fb67c48d04807c999759f5011a0.tar.gz gdb-508c39462ab96fb67c48d04807c999759f5011a0.tar.bz2 |
2006-02-24 H.J. Lu <hongjiu.lu@intel.com>
PR ld/2218
* elf-bfd.h (elf_backend_data): Add elf_backend_fixup_symbol.
(_bfd_elf_link_hash_fixup_symbol): New.
* elflink.c (_bfd_elf_link_hash_fixup_symbol): New.
(_bfd_elf_fix_symbol_flags): Call elf_backend_fixup_symbol if
it isn't NULL.
* elfxx-ia64.c (elf_backend_fixup_symbol): Defined.
* elfxx-target.h (elf_backend_fixup_symbol): New.
(elfNN_bed): Initialize elf_backend_fixup_symbol.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index bbd3770..9a99b06 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -2187,6 +2187,20 @@ _bfd_elf_link_output_relocs (bfd *output_bfd, return TRUE; } +/* Make weak undefined symbols in PIE dynamic. */ + +bfd_boolean +_bfd_elf_link_hash_fixup_symbol (struct bfd_link_info *info, + struct elf_link_hash_entry *h) +{ + if (info->pie + && h->dynindx == -1 + && h->root.type == bfd_link_hash_undefweak) + return bfd_elf_link_record_dynamic_symbol (info, h); + + return TRUE; +} + /* Fix up the flags for a symbol. This handles various cases which can only be fixed after all the input files are seen. This is currently called by both adjust_dynamic_symbol and @@ -2197,6 +2211,8 @@ bfd_boolean _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h, struct elf_info_failed *eif) { + const struct elf_backend_data *bed = NULL; + /* If this symbol was mentioned in a non-ELF file, try to set DEF_REGULAR and REF_REGULAR correctly. This is the only way to permit a non-ELF file to correctly refer to a symbol defined in @@ -2255,6 +2271,15 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h, h->def_regular = 1; } + /* Backend specific symbol fixup. */ + if (elf_hash_table (eif->info)->dynobj) + { + bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj); + if (bed->elf_backend_fixup_symbol + && !(*bed->elf_backend_fixup_symbol) (eif->info, h)) + return FALSE; + } + /* If this is a final link, and the symbol was defined as a common symbol in a regular object file, and there was no definition in any dynamic object, then the linker will have allocated space for @@ -2280,11 +2305,8 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h, || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT) && h->def_regular) { - const struct elf_backend_data *bed; bfd_boolean force_local; - bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj); - force_local = (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN); (*bed->elf_backend_hide_symbol) (eif->info, h, force_local); @@ -2323,12 +2345,8 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h, if (weakdef->def_regular) h->u.weakdef = NULL; else - { - const struct elf_backend_data *bed; - - bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj); - (*bed->elf_backend_copy_indirect_symbol) (eif->info, weakdef, h); - } + (*bed->elf_backend_copy_indirect_symbol) (eif->info, weakdef, + h); } return TRUE; |