This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: objcopy --redefine-sym(s) segfaults on mach-o-i386


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.


	* 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,
 	  /* 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 <> wrote:

> Hello,
> objcopy crashes very often when renaming symbols in mach-o-i386 object files.
> I've uploaded a coredump  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)
> 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>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]