Test results of bfd function calls in pe.em
Nick Clifton
nickc@redhat.com
Mon Oct 16 12:08:00 GMT 2000
More information about the Binutils mailing list
Mon Oct 16 12:08:00 GMT 2000
- Previous message (by thread): 2.10.91: The target of MIPS jump instructions is handled wrong
- Next message (by thread): Patch to add --srec-len and --srec-forceS3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Guys, Further to the tidying changes I made to pe.em last week, I have now applied the patch below to add some tests of the return values from some of the bfd functions that get called. Cheers Nick 2000-10-16 Nick Clifton <nickc@redhat.com> * emultempl/pe.em (_after_open): Add tests of return values from bfd functions. Emit appropriate error messages if necessary. Index: emultempl/pe.em =================================================================== RCS file: /cvs/src//src/ld/emultempl/pe.em,v retrieving revision 1.36 diff -p -r1.36 pe.em *** pe.em 2000/10/13 20:41:08 1.36 --- pe.em 2000/10/16 18:41:57 *************** gld_${EMULATION_NAME}_after_open () *** 848,900 **** is_imp = 1; reloc_count += sec->reloc_count; } if (is_imp && !idata2 && reloc_count) { ! /* it is, look for the reference to head and see if it's ! from our own library */ for (sec = is->the_bfd->sections; sec; sec = sec->next) { int i; ! int symsize; asymbol **symbols; - int relsize; arelent **relocs; int nrelocs; symsize = bfd_get_symtab_upper_bound (is->the_bfd); ! symbols = (asymbol **) xmalloc (symsize); ! bfd_canonicalize_symtab (is->the_bfd, symbols); relsize = bfd_get_reloc_upper_bound (is->the_bfd, sec); relocs = (arelent **) xmalloc ((size_t) relsize); nrelocs = bfd_canonicalize_reloc (is->the_bfd, sec, relocs, symbols); ! for (i=0; i<nrelocs; i++) { struct symbol_cache_entry *s; s = (relocs[i]->sym_ptr_ptr)[0]; ! if (!s->flags & BSF_LOCAL) ! { ! /* thunk section with reloc to another bfd... */ ! struct bfd_link_hash_entry *blhe; ! blhe = bfd_link_hash_lookup (link_info.hash, ! s->name, ! false, false, true); ! if (blhe && blhe->type == bfd_link_hash_defined) ! { ! bfd *other_bfd = blhe->u.def.section->owner; ! if (strcmp (is->the_bfd->my_archive->filename, ! other_bfd->my_archive->filename)) ! { ! /* Rename this implib to match the other */ ! char *n = (char *) xmalloc (strlen (other_bfd->my_archive->filename) + 1); ! strcpy (n, other_bfd->my_archive->filename); ! is->the_bfd->my_archive->filename = n; ! } ! } ! } } free (relocs); } } } --- 849,931 ---- is_imp = 1; reloc_count += sec->reloc_count; } + if (is_imp && !idata2 && reloc_count) { ! /* It is, look for the reference to head and see if it's ! from our own library. */ 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) + { + einfo ("%X%P: unable to process symbols: %E"); + return; + } + relocs = (arelent **) xmalloc ((size_t) relsize); nrelocs = bfd_canonicalize_reloc (is->the_bfd, sec, relocs, symbols); ! if (nrelocs < 0) ! { ! free (relocs); ! einfo ("%X%P: unable to process relocs: %E"); ! return; ! } ! ! for (i = 0; i < nrelocs; i++) { struct symbol_cache_entry *s; + struct bfd_link_hash_entry * blhe; + bfd *other_bfd; + char *n; + s = (relocs[i]->sym_ptr_ptr)[0]; ! ! if (s->flags & BSF_LOCAL) ! continue; ! ! /* Thunk section with reloc to another bfd. */ ! blhe = bfd_link_hash_lookup (link_info.hash, ! s->name, ! false, false, true); ! ! if (blhe == NULL ! || blhe->type != bfd_link_hash_defined) ! continue; ! ! other_bfd = blhe->u.def.section->owner; ! ! if (strcmp (is->the_bfd->my_archive->filename, ! other_bfd->my_archive->filename) == 0) ! continue; ! ! /* Rename this implib to match the other. */ ! n = (char *) xmalloc (strlen (other_bfd->my_archive->filename) + 1); ! ! strcpy (n, other_bfd->my_archive->filename); ! ! is->the_bfd->my_archive->filename = n; } free (relocs); + /* Note - we do not free the symbols, + they are now cached in the BFD. */ } } }
- Previous message (by thread): 2.10.91: The target of MIPS jump instructions is handled wrong
- Next message (by thread): Patch to add --srec-len and --srec-forceS3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list