This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH,ppc] fix segfaults when relocating against undefined symbols
- From: Nathan Froyd <froydnj at codesourcery dot com>
- To: binutils at sourceware dot org
- Date: Tue, 9 Oct 2007 11:15:42 -0700
- Subject: [PATCH,ppc] fix segfaults when relocating against undefined symbols
The attached patch fixes a problem with relocation processing on PPC
targets: if we have relocations against undefined symbols, then we will
crash when actually attempting to process the relocations, as there will
be no section to place the required bits in.
Fixed by simply continuing to process relocations in such cases;
warnings and/or errors about undefined symbols will ensure that we give
the user appropriate notice about what is going wrong.
Tested on powerpc-wrs-vxworks, OK to apply?
-Nathan
2007-10-09 Nathan Froyd <froydnj@codesourcery.com>
* elf32-ppc.c (ppc_elf_relocate_section): Continue processing
relocations if the output section is NULL; this guards against
relocations against global undefined symbols bombing out.
Index: bfd/elf32-ppc.c
===================================================================
--- bfd/elf32-ppc.c (revision 184409)
+++ bfd/elf32-ppc.c (working copy)
@@ -6527,7 +6527,8 @@ ppc_elf_relocate_section (bfd *output_bf
an embedded ELF object, for which the .got section acts like the
AIX .toc section. */
case R_PPC_TOC16: /* phony GOT16 relocations */
- BFD_ASSERT (sec != NULL);
+ if (sec == NULL)
+ continue;
BFD_ASSERT (bfd_is_und_section (sec)
|| strcmp (bfd_get_section_name (abfd, sec), ".got") == 0
|| strcmp (bfd_get_section_name (abfd, sec), ".cgot") == 0);
@@ -6569,7 +6570,8 @@ ppc_elf_relocate_section (bfd *output_bf
const char *name;
struct elf_link_hash_entry *sh;
- BFD_ASSERT (sec != NULL);
+ if (sec == NULL)
+ continue;
name = bfd_get_section_name (abfd, sec->output_section);
if (! ((CONST_STRNEQ (name, ".sdata")
&& (name[6] == 0 || name[6] == '.'))
@@ -6606,7 +6608,8 @@ ppc_elf_relocate_section (bfd *output_bf
const char *name;
struct elf_link_hash_entry *sh;
- BFD_ASSERT (sec != NULL);
+ if (sec == NULL)
+ continue;
name = bfd_get_section_name (abfd, sec->output_section);
if (! (CONST_STRNEQ (name, ".sdata2")
|| CONST_STRNEQ (name, ".sbss2")))
@@ -6647,7 +6650,8 @@ ppc_elf_relocate_section (bfd *output_bf
int reg;
struct elf_link_hash_entry *sh;
- BFD_ASSERT (sec != NULL);
+ if (sec == NULL)
+ continue;
name = bfd_get_section_name (abfd, sec->output_section);
if (((CONST_STRNEQ (name, ".sdata")
&& (name[6] == 0 || name[6] == '.'))
@@ -6724,7 +6728,8 @@ ppc_elf_relocate_section (bfd *output_bf
case R_PPC_SECTOFF_LO:
case R_PPC_SECTOFF_HI:
case R_PPC_SECTOFF_HA:
- BFD_ASSERT (sec != NULL);
+ if (sec == NULL)
+ continue;
addend -= sec->output_section->vma;
break;