objcopy --redefine-sym(s) segfaults on mach-o-i386
Tristan Gingold
gingold@adacore.com
Tue Apr 1 12:34:00 GMT 2014
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>
More information about the Binutils
mailing list