From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13542 invoked by alias); 1 Apr 2014 12:34:45 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 13533 invoked by uid 89); 1 Apr 2014 12:34:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.5 required=5.0 tests=AWL,BAYES_50,KAM_BADIPHTTP,NORMAL_HTTP_TO_IP autolearn=no version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 01 Apr 2014 12:34:44 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 4ADE22720044; Tue, 1 Apr 2014 14:34:41 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 97CsNzNxTZnL; Tue, 1 Apr 2014 14:34:41 +0200 (CEST) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 265D9272003E; Tue, 1 Apr 2014 14:34:41 +0200 (CEST) Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: objcopy --redefine-sym(s) segfaults on mach-o-i386 From: Tristan Gingold In-Reply-To: Date: Tue, 01 Apr 2014 12:34:00 -0000 Cc: binutils@sourceware.org Content-Transfer-Encoding: quoted-printable Message-Id: <0CC28F7D-C3B5-4760-953B-8E74A2CDADFC@adacore.com> References: To: Michael Opitz X-IsSubscribed: yes X-SW-Source: 2014-04/txt/msg00002.txt.bz2 Hello, I have modified mach-o.c to avoid the crash (I haven't yet testet with valg= rind). 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 =3D=3D 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 =3D syms + num; } - else if (num =3D=3D 0x00ffffff) + else if (num =3D=3D 0x00ffffff || num =3D=3D 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 !=3D 0); BFD_ASSERT (num <=3D mdata->nsects); =20 sym =3D mdata->sections[num - 1]->bfdsection->symbol_ptr_ptr; On 01 Apr 2014, at 12:28, Michael Opitz wrote: > Hello, >=20 > objcopy crashes very often when renaming symbols in mach-o-i386 object fi= les. > 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: >=20 > 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 ve= rsion. > This program has absolutely no warranty. >=20 > 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 >=20 > The problem is reproducible with recent binutils compiled on OSX. > I've also attached a valgrind logmessage. >=20 > Kind Regards, > Michael >