This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[Xtensa] fix segfault for non-ELF input to ld
- From: Bob Wilson <bwilson at tensilica dot com>
- To: binutils at sources dot redhat dot com
- Date: Wed, 18 Jul 2007 14:06:26 -0700
- Subject: [Xtensa] fix segfault for non-ELF input to ld
One of the uclibc makefiles runs "ld -b binary /dev/null" to check if a
command-line option is supported. This causes a segfault for Xtensa because it
expects to see only ELF inputs. I think it gets as far as it does only because
of the special case for "binary" targets in bfd_arch_get_compatible (in
archures.c). I've committed this patch to avoid the segfault; it isn't clear to
me that any more systematic checking for non-ELF files is necessary.
2007-07-18 Bob Wilson <bob.wilson@acm.org>
* elf32-xtensa.c (xtensa_callback_required_dependence): Ignore
non-ELF sections.
Index: elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.92
diff -u -p -r1.92 elf32-xtensa.c
--- elf32-xtensa.c 18 Jul 2007 18:23:47 -0000 1.92
+++ elf32-xtensa.c 18 Jul 2007 20:41:41 -0000
@@ -9805,6 +9805,11 @@ xtensa_callback_required_dependence (bfd
(*callback) (sec, sec_size, sgotplt, 0, closure);
}
+ /* Only ELF files are supported for Xtensa. Check here to avoid a segfault
+ when building uclibc, which runs "ld -b binary /dev/null". */
+ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
+ return ok;
+
internal_relocs = retrieve_internal_relocs (abfd, sec,
link_info->keep_memory);
if (internal_relocs == NULL