This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
[PATCH] Fix segfault relocating debugging sections on powerpc-*-linux-gnu
- To: binutils@sourceware.cygnus.com
- Subject: [PATCH] Fix segfault relocating debugging sections on powerpc-*-linux-gnu
- From: Daniel Jacobowitz <drow@false.org>
- Date: Thu, 29 Jul 1999 19:54:20 -0400
When the attached testcase is compiled on powerpc-linux with 'c++ -fPIC
-shared -g segvtest.cc' it causes a SEGV in the linker. Franz Sirl
noticed that elf32-i386.c specifically avoids relocations in sections
with SEC_DEBUGGING set; this patch adds the same to elf32-ppc.c. It
also copies the warning from elf32-i386.c in the same situation; the if
condition here (here being elf32-ppc.c:3000 or so) does not obviously
guarantee that output_section will not be NULL, and there could be
other cases it misses. I see no reason to have ld segfault
mysteriously :)
I would have added a testcase, but the organization of ld/testsuite/
eludes me.
[Please CC: me in any list replies, I'm not on this list]
Dan
/--------------------------------\ /--------------------------------\
| Daniel Jacobowitz |__| SCS Class of 2002 |
| Debian GNU/Linux Developer __ Carnegie Mellon University |
| dan@debian.org | | dmj+@andrew.cmu.edu |
\--------------------------------/ \--------------------------------/
/* $Id: pathname.cc,v 1.1 1999/07/25 19:59:49 drow Exp $ */
#include <sys/param.h>
#include <string.h>
#include <stack>
struct PathName {
stack<int> dirOffsets;
int curDirOffset;
void Push();
};
void PathName::Push()
{
dirOffsets.push(curDirOffset);
}
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/elf32-ppc.c,v
retrieving revision 1.6
diff -c -p -r1.6 elf32-ppc.c
*** elf32-ppc.c 1999/07/13 18:21:22 1.6
--- elf32-ppc.c 1999/07/29 23:32:10
*************** ppc_elf_relocate_section (output_bfd, in
*** 3038,3044 ****
&& ((! info->symbolic && h->dynindx != -1)
|| (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0)
! && (input_section->flags & SEC_ALLOC) != 0
&& (r_type == R_PPC_ADDR32
|| r_type == R_PPC_ADDR24
|| r_type == R_PPC_ADDR16
--- 3038,3045 ----
&& ((! info->symbolic && h->dynindx != -1)
|| (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0)
! && ((input_section->flags & SEC_ALLOC) != 0
! || (input_section->flags & SEC_DEBUGGING) != 0)
&& (r_type == R_PPC_ADDR32
|| r_type == R_PPC_ADDR24
|| r_type == R_PPC_ADDR16
*************** ppc_elf_relocate_section (output_bfd, in
*** 3081,3086 ****
--- 3082,3095 ----
obscure cases sec->output_section will be NULL. */
relocation = 0;
}
+ else if (sec->output_section == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
+ bfd_get_filename (input_bfd), h->root.root.string,
+ bfd_get_section_name (input_bfd, input_section));
+ relocation = 0;
+ }
else
relocation = (h->root.u.def.value
+ sec->output_section->vma