diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2006-09-07 17:16:34 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2006-09-07 17:16:34 +0000 |
commit | 55255daec3c2b3f212acfdfe9cefe9fd2899253f (patch) | |
tree | 1c54880b4a75b647aa760b69aa0c746024b269c3 /bfd | |
parent | 7c94efc52259df93dbe9aa3e4dcb1334bd460aef (diff) | |
download | gdb-55255daec3c2b3f212acfdfe9cefe9fd2899253f.zip gdb-55255daec3c2b3f212acfdfe9cefe9fd2899253f.tar.gz gdb-55255daec3c2b3f212acfdfe9cefe9fd2899253f.tar.bz2 |
bfd/
2006-09-07 H.J. Lu <hongjiu.lu@intel.com>
* elf-bfd.h (elf_link_hash_entry): Add a dynamic field.
(bfd_elf_link_mark_dynamic_symbol): New.
(SYMBOLIC_BIND): New.
* elf32-i386.c (elf_i386_check_relocs): Replace info->symbolic
with SYMBOLIC_BIND (info, h).
(elf_i386_relocate_section): Likewise.
* elf64-x86-64.c (elf64_x86_64_check_relocs): Likewise.
(elf64_x86_64_relocate_section): Likewise.
* elfxx-ia64.c (elfNN_ia64_check_relocs): Likewise.
* elflink.c (bfd_elf_link_mark_dynamic_symbol): New.
(bfd_elf_record_link_assignment): Call
bfd_elf_link_mark_dynamic_symbol on new entry.
(_bfd_elf_merge_symbol): Likewise.
(_bfd_elf_export_symbol): Return if the symbol isn't exported.
(_bfd_elf_fix_symbol_flags): Replace info->symbolic with
SYMBOLIC_BIND (info, h).
(_bfd_elf_dynamic_symbol_p): Likewise.
(_bfd_elf_symbol_refs_local_p): Likewise.
(bfd_elf_size_dynamic_sections): Updated.
include/
2006-09-07 H.J. Lu <hongjiu.lu@intel.com>
* bfdlink.h (bfd_elf_dynamic_list): New.
(bfd_link_info): Add a dynamic field.
ld/
2006-09-07 H.J. Lu <hongjiu.lu@intel.com>
* Makefile.am (CXX): Set to g++.
(CXX_FOR_TARGET): Likewise.
* Makefile.in: Regenerated.
* NEWS: Mention --dynamic-list.
* ld.texinfo: Document --dynamic-list.
* ldgram.y: Support dynamic list.
* ldlang.c (lang_process): Call lang_finalize_version_expr_head
on link_info.dynamic if needed.
(lang_append_dynamic_list): New.
(lang_append_dynamic_list_cpp_typeinfo): New.
* ldlang.h (lang_append_dynamic_list): Likewise.
* ldlang.h (lang_append_dynamic_list_cpp_typeinfo): Likewise.
* ldlex.h (input_enum): Add input_dynamic_list.
* ldlex.l: Handle it.
* ldmain.c (main): Initialize link_info.dynamic.
* lexsup.c (option_values): Add OPTION_DYNAMIC_LIST and
OPTION_DYNAMIC_LIST_CPP_TYPEINFO.
(ld_options): Add entries for OPTION_DYNAMIC_LIST and
OPTION_DYNAMIC_LIST_CPP_TYPEINFO.
(parse_args): Handle OPTION_DYNAMIC_LIST and
OPTION_DYNAMIC_LIST_CPP_TYPEINFO.
ld/testsuite/
2006-09-07 H.J. Lu <hongjiu.lu@intel.com>
* ld-elf/dl1.c: New file.
* ld-elf/dl1.list: Likewise.
* ld-elf/dl1.out: Likewise.
* ld-elf/dl1main.c: Likewise.
* ld-elf/dl2.c: Likewise.
* ld-elf/dl2.list: Likewise.
* ld-elf/dl2a.out: Likewise.
* ld-elf/dl2b.out: Likewise.
* ld-elf/dl2main.c: Likewise.
* ld-elf/dl2xxx.c: Likewise.
* ld-elf/dl2xxx.list: Likewise.
* ld-elf/dl3.cc: Likewise.
* ld-elf/dl3.list: Likewise.
* ld-elf/dl3a.out: Likewise.
* ld-elf/dl3b.out: Likewise.
* ld-elf/dl3header.h: Likewise.
* ld-elf/dl3main.cc: Likewise.
* ld-elf/shared.exp: Updated.
* lib/ld-lib.exp (run_ld_link_exec_tests): Take an optional
argument for source language. Use CC/CXX for link, depending
on source language.
(run_cc_link_tests): Likewise.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 24 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 10 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 4 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 4 | ||||
-rw-r--r-- | bfd/elflink.c | 34 | ||||
-rw-r--r-- | bfd/elfxx-ia64.c | 4 |
6 files changed, 69 insertions, 11 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5df36f3..88cff5c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,27 @@ +2006-09-07 H.J. Lu <hongjiu.lu@intel.com> + + * elf-bfd.h (elf_link_hash_entry): Add a dynamic field. + (bfd_elf_link_mark_dynamic_symbol): New. + (SYMBOLIC_BIND): New. + + * elf32-i386.c (elf_i386_check_relocs): Replace info->symbolic + with SYMBOLIC_BIND (info, h). + (elf_i386_relocate_section): Likewise. + * elf64-x86-64.c (elf64_x86_64_check_relocs): Likewise. + (elf64_x86_64_relocate_section): Likewise. + * elfxx-ia64.c (elfNN_ia64_check_relocs): Likewise. + + * elflink.c (bfd_elf_link_mark_dynamic_symbol): New. + (bfd_elf_record_link_assignment): Call + bfd_elf_link_mark_dynamic_symbol on new entry. + (_bfd_elf_merge_symbol): Likewise. + (_bfd_elf_export_symbol): Return if the symbol isn't exported. + (_bfd_elf_fix_symbol_flags): Replace info->symbolic with + SYMBOLIC_BIND (info, h). + (_bfd_elf_dynamic_symbol_p): Likewise. + (_bfd_elf_symbol_refs_local_p): Likewise. + (bfd_elf_size_dynamic_sections): Updated. + 2006-09-05 Bibo Mao <bibo.mao@intel.com> PR binutils/3171 diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index e7d3b18..32b381c 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -155,6 +155,8 @@ struct elf_link_hash_entry unsigned int hidden : 1; /* Symbol was forced to local scope due to a version script file. */ unsigned int forced_local : 1; + /* Symbol was forced to be dynamic due to a version script file. */ + unsigned int dynamic : 1; /* Symbol was marked during garbage collection. */ unsigned int mark : 1; /* Symbol is referenced by a non-GOT/non-PLT relocation. This is @@ -1828,6 +1830,9 @@ extern bfd_boolean bfd_elf_link_record_dynamic_symbol extern int bfd_elf_link_record_local_dynamic_symbol (struct bfd_link_info *, bfd *, long); +extern void bfd_elf_link_mark_dynamic_symbol + (struct bfd_link_info *, struct elf_link_hash_entry *); + extern bfd_boolean _bfd_elf_close_and_cleanup (bfd *); @@ -1980,4 +1985,9 @@ extern bfd_boolean _sh_elf_set_mach_from_flags } \ while (0) +/* Will a symbol be bound to the the definition within the shared + library, if any. */ +#define SYMBOLIC_BIND(INFO, H) \ + ((INFO)->symbolic || ((INFO)->dynamic && !(H)->dynamic)) + #endif /* _LIBELF_H_ */ diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index ab02b2c..7fb1422 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1150,7 +1150,7 @@ elf_i386_check_relocs (bfd *abfd, && (sec->flags & SEC_ALLOC) != 0 && (r_type != R_386_PC32 || (h != NULL - && (! info->symbolic + && (! SYMBOLIC_BIND (info, h) || h->root.type == bfd_link_hash_defweak || !h->def_regular)))) || (ELIMINATE_COPY_RELOCS @@ -2629,7 +2629,7 @@ elf_i386_relocate_section (bfd *output_bfd, && h->dynindx != -1 && (r_type == R_386_PC32 || !info->shared - || !info->symbolic + || !SYMBOLIC_BIND (info, h) || !h->def_regular)) outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); else diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 34fde96..d84b82e 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -997,7 +997,7 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, && (r_type != R_X86_64_PC32) && (r_type != R_X86_64_PC64)) || (h != NULL - && (! info->symbolic + && (! SYMBOLIC_BIND (info, h) || h->root.type == bfd_link_hash_defweak || !h->def_regular)))) || (ELIMINATE_COPY_RELOCS @@ -2445,7 +2445,7 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, || r_type == R_X86_64_PC32 || r_type == R_X86_64_PC64 || !info->shared - || !info->symbolic + || !SYMBOLIC_BIND (info, h) || !h->def_regular)) { outrel.r_info = ELF64_R_INFO (h->dynindx, r_type); diff --git a/bfd/elflink.c b/bfd/elflink.c index a7657f9..d3f9b62 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -444,6 +444,21 @@ bfd_elf_link_record_dynamic_symbol (struct bfd_link_info *info, return TRUE; } +/* Mark a symbol dynamic. */ + +void +bfd_elf_link_mark_dynamic_symbol (struct bfd_link_info *info, + struct elf_link_hash_entry *h) +{ + struct bfd_elf_dynamic_list *d = info->dynamic; + + if (d == NULL || info->relocatable) + return; + + if ((*d->match) (&d->head, NULL, h->root.root.string)) + h->dynamic = 1; +} + /* Record an assignment to a symbol made by a linker script. We need this in case some dynamic object refers to this symbol. */ @@ -477,7 +492,10 @@ bfd_elf_record_link_assignment (bfd *output_bfd, } if (h->root.type == bfd_link_hash_new) - h->non_elf = 0; + { + bfd_elf_link_mark_dynamic_symbol (info, h); + h->non_elf = 0; + } /* If this symbol is being provided by the linker script, and it is currently defined by a dynamic object, but not by a regular @@ -840,6 +858,7 @@ _bfd_elf_merge_symbol (bfd *abfd, if (h->root.type == bfd_link_hash_new) { + bfd_elf_link_mark_dynamic_symbol (info, h); h->non_elf = 0; return TRUE; } @@ -1626,6 +1645,10 @@ _bfd_elf_export_symbol (struct elf_link_hash_entry *h, void *data) { struct elf_info_failed *eif = data; + /* Ignore this if we won't export it. */ + if (!eif->info->export_dynamic && !h->dynamic) + return TRUE; + /* Ignore indirect symbols. These are added by the versioning code. */ if (h->root.type == bfd_link_hash_indirect) return TRUE; @@ -2379,7 +2402,7 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h, if (h->needs_plt && eif->info->shared && is_elf_hash_table (eif->info->hash) - && (eif->info->symbolic + && (SYMBOLIC_BIND (eif->info, h) || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT) && h->def_regular) { @@ -2608,7 +2631,7 @@ _bfd_elf_dynamic_symbol_p (struct elf_link_hash_entry *h, /* Identify the cases where name binding rules say that a visible symbol resolves locally. */ - binding_stays_local_p = info->executable || info->symbolic; + binding_stays_local_p = info->executable || SYMBOLIC_BIND (info, h); switch (ELF_ST_VISIBILITY (h->other)) { @@ -2671,7 +2694,7 @@ _bfd_elf_symbol_refs_local_p (struct elf_link_hash_entry *h, /* At this point, we know the symbol is defined and dynamic. In an executable it must resolve locally, likewise when building symbolic shared libraries. */ - if (info->executable || info->symbolic) + if (info->executable || SYMBOLIC_BIND (info, h)) return TRUE; /* Now deal with defined dynamic symbols in shared libraries. Ones @@ -5322,7 +5345,8 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, /* If we are supposed to export all symbols into the dynamic symbol table (this is not the normal case), then do so. */ - if (info->export_dynamic) + if (info->export_dynamic + || (info->executable && info->dynamic)) { elf_link_hash_traverse (elf_hash_table (info), _bfd_elf_export_symbol, diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index 11bba4e..2af3fb4 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -2741,7 +2741,7 @@ elfNN_ia64_check_relocs (abfd, info, sec, relocs) have yet been processed. Do something with what we know, as this may help reduce memory usage and processing time later. */ maybe_dynamic = (h && ((!info->executable - && (!info->symbolic + && (!SYMBOLIC_BIND (info, h) || info->unresolved_syms_in_shared_libs == RM_IGNORE)) || !h->def_regular || h->root.type == bfd_link_hash_defweak)); @@ -2913,7 +2913,7 @@ elfNN_ia64_check_relocs (abfd, info, sec, relocs) have yet been processed. Do something with what we know, as this may help reduce memory usage and processing time later. */ maybe_dynamic = (h && ((!info->executable - && (!info->symbolic + && (!SYMBOLIC_BIND (info, h) || info->unresolved_syms_in_shared_libs == RM_IGNORE)) || !h->def_regular || h->root.type == bfd_link_hash_defweak)); |