This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Fix ld segfault with MALLOC_PERTURB_=36
- From: Jakub Jelinek <jakub at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Sat, 14 Apr 2007 03:48:50 +0200
- Subject: [PATCH] Fix ld segfault with MALLOC_PERTURB_=36
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
echo 'SECTIONS { foo : { *(.data) } }' > x.lds
MALLOC_PERTURB_=36 ld -m elf_i386 -r --format binary --oformat elf32-i386 -T x.lds x.lds -o x.o
crashes, as info->input_bfds is binary flavour, not elf and
therefore *elf_tdata (sub) contains unrelated garbage.
The following patch fixes that.
Ok to commit?
I wonder whether the following hunk in bfd_elf_size_dynamic_sections
doesn't need the same treatment:
for (sub = info->input_bfds; sub != NULL;
sub = sub->link_next)
for (o = sub->sections; o != NULL; o = o->next)
if (elf_section_data (o)->this_hdr.sh_type
== SHT_PREINIT_ARRAY)
2007-04-13 Jakub Jelinek <jakub@redhat.com>
* elflink.c (bfd_elf_final_link): Don't free symbuf if
input bfd is not elf.
--- bfd/elflink.c.jj 2007-04-07 10:19:03.000000000 +0200
+++ bfd/elflink.c 2007-04-14 02:58:02.000000000 +0200
@@ -9533,7 +9533,8 @@ bfd_elf_final_link (bfd *abfd, struct bf
if (!info->reduce_memory_overheads)
{
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
- if (elf_tdata (sub)->symbuf)
+ if (bfd_get_flavour (sub) == bfd_target_elf_flavour
+ && elf_tdata (sub)->symbuf)
{
free (elf_tdata (sub)->symbuf);
elf_tdata (sub)->symbuf = NULL;
Jakub