The problem is that clang-1000.11.45.2
distributed with Apple LLVM version 10.0.0
adds a new load command to o-mach executables named LC_BUILD_VERSION
.
$ otool -l test.o
...
Load command 1
cmd LC_BUILD_VERSION
cmdsize 24
platform macos
sdk n/a
minos 10.14
ntools 0
...
From the apple source:
/*
* The build_version_command contains the min OS version on which this
* binary was built to run for its platform. The list of known platforms and
* tool values following it.
*/
So currently bfd
(the program used by gdb to manipulate executables) is not able to interpret this command and returns the error.
As a temporary solution, you can edit the bfd
sources code provides with gdb
.
First, download gdb-8.0.1
sources from mirrors. Then add to gdb-8.0.1/bfd/mach-o.c
the following code at line 4649
:
case BFD_MACH_O_LC_BUILD_VERSION:
break;
Finally inside gdb-8.0.1/include/mach-o/loader.h
at line 189
:
BFD_MACH_O_LC_BUILD_VERSION = 0x32
Don't forget to add a ,
at the end of the line 188 after BFD_MACH_O_LC_VERSION_MIN_WATCHOS = 0x30
).
Then process a classic gdb
compilation following instructions from the README :
run the ``configure'' script here, e.g.:
./configure
make
To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
make install
Don't forget to sign gdb
as explain here.
If you still get the (os/kern) failure (0x5) error, just run sudo gdb
.
This is a temporary solution in order to wait for a fix from GNU team.
EDIT
Binutils-gdb
has been updated, these changes are now implemented in commit fc7b364.
Hope It will be helpful.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…