public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Tristan Gingold <gingold@adacore.com>
To: Michael Opitz <opitz.michael@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: objcopy --redefine-sym(s) segfaults on mach-o-i386
Date: Tue, 01 Apr 2014 12:34:00 -0000	[thread overview]
Message-ID: <0CC28F7D-C3B5-4760-953B-8E74A2CDADFC@adacore.com> (raw)
In-Reply-To: <CAGSuVoyG7145v7pAQO7WS562jf-HgW41Xbe3uc_dL-zZ8_XSAQ@mail.gmail.com>

Hello,

I have modified mach-o.c to avoid the crash (I haven't yet testet with valgrind).

Do you have the C source of test 2 ?  It looks to be not well formed.

Tristan.

bfd/
	* mach-o.c (bfd_mach_o_canonicalize_one_reloc): Avoid to crash
	when num == 0.

diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index ebaa6c7..e33c01f 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -1075,7 +1075,7 @@ bfd_mach_o_canonicalize_one_reloc (bfd *abfd,
 	  /* An external symbol number.  */
 	  sym = syms + num;
 	}
-      else if (num == 0x00ffffff)
+      else if (num == 0x00ffffff || num == 0)
 	{
 	  /* The 'symnum' in a non-scattered PAIR is 0x00ffffff.  But as this
 	     is generic code, we don't know wether this is really a PAIR.
@@ -1087,7 +1087,6 @@ bfd_mach_o_canonicalize_one_reloc (bfd *abfd,
       else
         {
 	  /* A section number.  */
-          BFD_ASSERT (num != 0);
           BFD_ASSERT (num <= mdata->nsects);
 
           sym = mdata->sections[num - 1]->bfdsection->symbol_ptr_ptr;

On 01 Apr 2014, at 12:28, Michael Opitz <opitz.michael@gmail.com> wrote:

> Hello,
> 
> objcopy crashes very often when renaming symbols in mach-o-i386 object files.
> I've uploaded a coredump http://176.28.14.46/core.24966  and a small
> object file with which the crash happened.
> The coredump was generated on linux x86_64
> The binutils version is:
> 
> x86_64-apple-darwin-objcopy --version
> GNU objcopy (GNU Binutils) 2.24.51.20140331
> Copyright (C) 2014 Free Software Foundation, Inc.
> This program is free software; you may redistribute it under the terms of
> the GNU General Public License version 3 or (at your option) any later version.
> This program has absolutely no warranty.
> 
> The binary was compiled on Mountain Lion with gcc -m32 -c test.c -o test.o
> where gcc is really a link on clang:
> gcc --version
> Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
> Target: x86_64-apple-darwin12.5.0
> Thread model: posix
> 
> The problem is reproducible with recent binutils compiled on OSX.
> I've also attached a valgrind logmessage.
> 
> Kind Regards,
> Michael
> <valgrind.log><test (2).o>

      reply	other threads:[~2014-04-01 12:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-01 10:29 Michael Opitz
2014-04-01 12:34 ` Tristan Gingold [this message]

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=0CC28F7D-C3B5-4760-953B-8E74A2CDADFC@adacore.com \
    --to=gingold@adacore.com \
    --cc=binutils@sourceware.org \
    --cc=opitz.michael@gmail.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).