diff options
author | Alan Modra <amodra@gmail.com> | 2008-08-17 03:12:50 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2008-08-17 03:12:50 +0000 |
commit | 5c1d2f5f4c7747c36eae8be3abd4ef4e9669690c (patch) | |
tree | 3be4145ee7086fe0315ad0ce506626b5ca560759 /ld/emultempl | |
parent | 1f5064de53c27d99fb92efd65a6785e2f1ec0835 (diff) | |
download | gdb-5c1d2f5f4c7747c36eae8be3abd4ef4e9669690c.zip gdb-5c1d2f5f4c7747c36eae8be3abd4ef4e9669690c.tar.gz gdb-5c1d2f5f4c7747c36eae8be3abd4ef4e9669690c.tar.bz2 |
bfd/
* bfd.c (struct _bfd): Correct outsymbols comment.
* bfd-in2.h: Regenerate.
* linker.c (bfd_generic_link_read_symbols): Renamed from..
(generic_link_read_symbols): ..this, and made global.
include/
* bfdlink.h (bfd_generic_link_read_symbols): Declare.
ld/
PR 6478
* ldcref.c (check_local_sym_xref): Use bfd_generic_link_read_symbols.
Don't free symbol pointer array.
(check_refs): Likewise.
* ldmain.c (warning_callback): Likewise.
* ldmisc.c (vfinfo): Likewise.
* pe-dll.c (process_def_file): Likewise.
(pe_walk_relocs_of_symbol, generate_reloc): Likewise.
* emultempl/pe.em (pe_find_data_imports): Likewise.
(gld_${EMULATION_NAME}_after_open): Likewise.
* emultempl/pep.em (pep_find_data_imports): Likewise.
(gld_${EMULATION_NAME}_after_open): Likewise.
* ldlang.h (lang_input_statement_type): Delete asymbols, symbol_count,
passive_position, closed.
* ldlang.c (new_afile): Don't set asymbols and symbol_count.
* ldmain.c (add_archive_element): xcalloc lang_input_statement_type.
Diffstat (limited to 'ld/emultempl')
-rw-r--r-- | ld/emultempl/pe.em | 42 | ||||
-rw-r--r-- | ld/emultempl/pep.em | 25 |
2 files changed, 36 insertions, 31 deletions
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 08cfcfc..865cfaa 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -922,7 +922,7 @@ pe_find_data_imports (void) { bfd *b = sym->u.def.section->owner; asymbol **symbols; - int nsyms, symsize, i; + int nsyms, i; if (link_info.pei386_auto_import == -1) { @@ -940,9 +940,14 @@ This should work unless it involves constant data structures referencing symbols } } - symsize = bfd_get_symtab_upper_bound (b); - symbols = (asymbol **) xmalloc (symsize); - nsyms = bfd_canonicalize_symtab (b, symbols); + if (!bfd_generic_link_read_symbols (b)) + { + einfo (_("%B%F: could not read symbols: %E\n"), b); + return; + } + + symbols = bfd_get_outsymbols (b); + nsyms = bfd_get_symcount (b); for (i = 0; i < nsyms; i++) { @@ -1094,26 +1099,22 @@ gld_${EMULATION_NAME}_after_open (void) for (sec = is->the_bfd->sections; sec; sec = sec->next) { int i; - long symsize; long relsize; asymbol **symbols; arelent **relocs; int nrelocs; - symsize = bfd_get_symtab_upper_bound (is->the_bfd); - if (symsize < 1) - break; relsize = bfd_get_reloc_upper_bound (is->the_bfd, sec); if (relsize < 1) break; - symbols = (asymbol **) xmalloc (symsize); - symsize = bfd_canonicalize_symtab (is->the_bfd, symbols); - if (symsize < 0) + if (!bfd_generic_link_read_symbols (is->the_bfd)) { - einfo ("%X%P: unable to process symbols: %E"); + einfo (_("%B%F: could not read symbols: %E\n"), + is->the_bfd); return; } + symbols = bfd_get_outsymbols (is->the_bfd); relocs = (arelent **) xmalloc ((size_t) relsize); nrelocs = bfd_canonicalize_reloc (is->the_bfd, sec, @@ -1309,16 +1310,20 @@ gld_${EMULATION_NAME}_after_open (void) if (is_imp && stub_sec) { - long symsize; asymbol **symbols; - long src_count; + long nsyms, src_count; struct bfd_link_hash_entry * blhe; - symsize = bfd_get_symtab_upper_bound (is->the_bfd); - symbols = xmalloc (symsize); - symsize = bfd_canonicalize_symtab (is->the_bfd, symbols); + if (!bfd_generic_link_read_symbols (is->the_bfd)) + { + einfo (_("%B%F: could not read symbols: %E\n"), + is->the_bfd); + return; + } + symbols = bfd_get_outsymbols (is->the_bfd); + nsyms = bfd_get_symcount (is->the_bfd); - for (src_count = 0; src_count < symsize; src_count++) + for (src_count = 0; src_count < nsyms; src_count++) { if (symbols[src_count]->section->id == stub_sec->id) { @@ -1335,7 +1340,6 @@ gld_${EMULATION_NAME}_after_open (void) stub_sec->flags |= SEC_EXCLUDE; } } - free (symbols); } } } diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index 2fae386..21bcf01 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -881,7 +881,7 @@ pep_find_data_imports (void) { bfd *b = sym->u.def.section->owner; asymbol **symbols; - int nsyms, symsize, i; + int nsyms, i; if (link_info.pei386_auto_import == -1) { @@ -899,9 +899,14 @@ This should work unless it involves constant data structures referencing symbols } } - symsize = bfd_get_symtab_upper_bound (b); - symbols = xmalloc (symsize); - nsyms = bfd_canonicalize_symtab (b, symbols); + if (!bfd_generic_link_read_symbols (b)) + { + einfo (_("%B%F: could not read symbols: %E\n"), b); + return; + } + + symbols = bfd_get_outsymbols (b); + nsyms = bfd_get_symcount (b); for (i = 0; i < nsyms; i++) { @@ -1032,26 +1037,22 @@ gld_${EMULATION_NAME}_after_open (void) for (sec = is->the_bfd->sections; sec; sec = sec->next) { int i; - long symsize; long relsize; asymbol **symbols; arelent **relocs; int nrelocs; - symsize = bfd_get_symtab_upper_bound (is->the_bfd); - if (symsize < 1) - break; relsize = bfd_get_reloc_upper_bound (is->the_bfd, sec); if (relsize < 1) break; - symbols = xmalloc (symsize); - symsize = bfd_canonicalize_symtab (is->the_bfd, symbols); - if (symsize < 0) + if (!bfd_generic_link_read_symbols (is->the_bfd)) { - einfo ("%X%P: unable to process symbols: %E"); + einfo (_("%B%F: could not read symbols: %E\n"), + is->the_bfd); return; } + symbols = bfd_get_outsymbols (is->the_bfd); relocs = xmalloc ((size_t) relsize); nrelocs = bfd_canonicalize_reloc (is->the_bfd, sec, |