public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix ld segfault with MALLOC_PERTURB_=36
@ 2007-04-14  5:25 Jakub Jelinek
  2007-04-14 14:24 ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2007-04-14  5:25 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix ld segfault with MALLOC_PERTURB_=36
  2007-04-14  5:25 [PATCH] Fix ld segfault with MALLOC_PERTURB_=36 Jakub Jelinek
@ 2007-04-14 14:24 ` Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2007-04-14 14:24 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: binutils

On Sat, Apr 14, 2007 at 03:48:50AM +0200, Jakub Jelinek wrote:
> 	* elflink.c (bfd_elf_final_link): Don't free symbuf if
> 	input bfd is not elf.

OK.  Similar fix for bfd_elf_size_dynamic_sections preapproved.  It
needs it.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-04-14  5:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-14  5:25 [PATCH] Fix ld segfault with MALLOC_PERTURB_=36 Jakub Jelinek
2007-04-14 14:24 ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).