Fix reloc handling around elf_backend_count_relocs
Alan Modra
amodra@bigpond.net.au
Mon May 7 14:46:00 GMT 2007
Segfaults, bogus free(). Apparently this code was never tested.
Also an unrelated patch: bfd_elf_discard_info doesn't return an error
condition, so return an error to the linker via einfo.
* elflink.c (bfd_elf_final_link): Correct reloc handling for
elf_backend_count_relocs.
(bfd_elf_discard_info): Print an error if we can't read syms.
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.260
diff -u -p -r1.260 elflink.c
--- bfd/elflink.c 4 May 2007 21:53:02 -0000 1.260
+++ bfd/elflink.c 7 May 2007 11:36:32 -0000
@@ -9312,13 +9312,18 @@ bfd_elf_final_link (bfd *abfd, struct bf
{
Elf_Internal_Rela * relocs;
- relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+ relocs = _bfd_elf_link_read_relocs (sec->owner, sec,
+ NULL, NULL,
info->keep_memory);
- reloc_count = (*bed->elf_backend_count_relocs) (sec, relocs);
+ if (relocs != NULL)
+ {
+ reloc_count
+ = (*bed->elf_backend_count_relocs) (sec, relocs);
- if (elf_section_data (o)->relocs != relocs)
- free (relocs);
+ if (elf_section_data (sec)->relocs != relocs)
+ free (relocs);
+ }
}
if (sec->rawsize > max_contents_size)
@@ -11147,7 +11152,10 @@ bfd_elf_discard_info (bfd *output_bfd, s
cookie.locsymcount, 0,
NULL, NULL, NULL);
if (cookie.locsyms == NULL)
- return FALSE;
+ {
+ info->callbacks->einfo (_("%P%X: can not read symbols: %E\n"));
+ return FALSE;
+ }
}
if (stab != NULL)
--
Alan Modra
IBM OzLabs - Linux Technology Centre
More information about the Binutils
mailing list