google / bindiff

Quickly find differences and similarities in disassembled code
https://zynamics.com/bindiff.html
Apache License 2.0
2.15k stars 130 forks source link

Linker issue with LTO symbols when using XCode 15.0.1 (or later) #31

Closed cblichmann closed 7 months ago

cblichmann commented 7 months ago

Describe the bug Using a Mac with XCode 15.0, configuring the CMake build and running cmake --build . --config Release (internally, this uses a the Makefile generator) gives this error:

...
[ 93%] Built target bindiff
0  0x109dabf43  __assert_rtn + 64
1  0x109d53a20  mach_o::Symbol ld::Layout::symbolForAtom<ld::LinkedAtomPlacement const>(ld::Atom const*, CString, ld::LinkedAtomPlacement const&, ld::DylibMapping const*, unsigned long long) const + 2384
2  0x109d4d44b  void dispatchForEach<ld::AtomAndName const, void ld::buildSymbolTable<ld::LinkedAtomPlacement>(ld::SymbolTableLayout&, ld::Layout const&, ld::Options const&, ld::AtomSymbolPartition const&, ld::LinkedAtomPlacement const&, ld::DylibMapping const*, unsigned long long, bool, bool)::'lambda1'(unsigned long, ld::AtomAndName const&)>(std::__1::span<ld::LinkedAtomPlacement, 18446744073709551615ul>, unsigned long, void ld::buildSymbolTable<ld::LinkedAtomPlacement>(ld::SymbolTableLayout&, ld::Layout const&, ld::Options const&, ld::AtomSymbolPartition const&, ld::LinkedAtomPlacement const&, ld::DylibMapping const*, unsigned long long, bool, bool)::'lambda1'(unsigned long, ld::AtomAndName const&))::'lambda'(unsigned long)::operator()(unsigned long) const + 187
3  0x109d5895b  ld::LayoutExecutable::writeToFile(char const*) + 9099
4  0x109cfaf9f  main + 12831
ld: Assertion failed: (0 && "lto symbol should not be in layout"), function symbolForAtom, file Layout.cpp, line 1381.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [call_graph_test] Error 1
make[1]: *** [CMakeFiles/call_graph_test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
ld: warning: ignoring duplicate libraries: '../_deps/absl-build/absl/time/libabsl_time.a'
ld: warning: ignoring duplicate libraries: '../_deps/absl-build/absl/time/libabsl_time.a'
ld: warning: ignoring duplicate libraries: '../_deps/absl-build/absl/time/libabsl_time.a'
[ 93%] Built target change_classifier_test
ld: warning: ignoring duplicate libraries: '../_deps/absl-build/absl/time/libabsl_time.a'
[ 94%] Built target bindiff8_ida.dylib
[ 97%] Built target bindiff8_ida64.dylib
make: *** [all] Error 2

To Reproduce Steps to reproduce the behavior:

  1. See above, configure CMake and run cmake --build . --config Release

Expected behavior Release binaries of BinDiff being built.

Screenshots N/A

Environment (please complete the following information):

Additional context As a workaround, the "classic" linker ld64 can be used instead of the new ld_prime one. See the XCode 15.0 Release Notes.

cblichmann commented 7 months ago

Fix is in https://github.com/google/binexport/commit/85c89a4ab96febcccc4cdc01ca5fc6c005e9a2cf.