public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: binutils@sources.redhat.com
Subject: [PATCH] Fix ld segfault with MALLOC_PERTURB_=36
Date: Sat, 14 Apr 2007 05:25:00 -0000	[thread overview]
Message-ID: <20070414014850.GJ1826@sunsite.mff.cuni.cz> (raw)

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

             reply	other threads:[~2007-04-14  1:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-14  5:25 Jakub Jelinek [this message]
2007-04-14 14:24 ` Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070414014850.GJ1826@sunsite.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=binutils@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).