Use lld to replace ld linker in OS X Xcode

ساخت وبلاگ

Vote count: 0

I am trying to do some hacking (I need to run the linker on a device to link some object files stored there) during the linking stage of Xcode on my ios app project. My first thought is to use the open-source lld linker to replace the native ld linker. I tried to replace ld with lld in the default xcode toolchain, and sent the same arguments to lld, but unfortunately many arguments are not recognized. If I remove these arguments, I get errors like:

Assertion failed : (dylib.file), function exports, file / var / root / Desktop / llvm / tools / lld / lib / ReaderWriter / MachO / File.h, line 302.
0 lld 0x00000001082043ee llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46
1 lld 0x0000000108204829 PrintStackTraceSignalHandler(void*) + 25
2 lld 0x0000000108201029 llvm::sys::RunSignalHandlers() + 425
3 lld 0x0000000108204b89 SignalHandler(int) + 345
4 libsystem_platform.dylib 0x00007fff86d1ceaa _sigtramp + 26
5 lld 0x000000010bc5cd9b SentinelFragment + 491531
6 lld 0x000000010820484b raise + 27
7 lld 0x0000000108204902 abort + 18
8 lld 0x00000001082048e1 __assert_rtn + 129
9 lld 0x000000010a557111 lld::mach_o::MachODylibFile::exports(llvm::StringRef, llvm::StringRef) const + 1617
10 lld 0x000000010a55717a lld::mach_o::MachODylibFile::exports(llvm::StringRef, llvm::StringRef) const + 1722
11 lld 0x000000010a556445 lld::mach_o::MachODylibFile::exports(llvm::StringRef, bool) const + 101
12 lld 0x000000010ab94088 lld::Resolver::handleSharedLibrary(lld::File&)::$_1::operator()(llvm::StringRef, bool) const + 104
13 lld 0x000000010ab9400b void std::__1::__invoke_void_retu_wrapper<void>::__call<lld::Resolver::handleSharedLibrary(lld::File&)::$_1&, llvm::StringRef, bool>(lld::Resolver::handleSharedLibrary(lld::File&)::$_1&&&, llvm::StringRef&&, bool&&) + 139
14 lld 0x000000010ab93f4c std::__1::__function::__func<lld::Resolver::handleSharedLibrary(lld::File&)::$_1, std::__1::allocator<lld::Resolver::handleSharedLibrary(lld::File&)::$_1>, void(llvm::StringRef, bool)>::operator()(llvm::StringRef&&, bool&&) + 76
15 lld 0x000000010ab9456e std::__1::function<void(llvm::StringRef, bool)>::operator()(llvm::StringRef, bool) const + 94
16 lld 0x000000010ab8cc7f lld::Resolver::forEachUndefines(lld::File&, bool, std::__1::function<void(llvm::StringRef, bool)>) + 591
17 lld 0x000000010ab8d213 lld::Resolver::handleSharedLibrary(lld::File&) + 179
18 lld 0x000000010ab8e4be lld::Resolver::resolveUndefines() + 1518
19 lld 0x000000010ab913cc lld::Resolver::resolve() + 108
20 lld 0x0000000108000413 lld::Driver::link(lld::LinkingContext&, llvm::raw_ostream&) + 5795
21 lld 0x0000000107feec9d lld::DarwinLdDriver::linkMachO(llvm::ArrayRef<char const*>, llvm::raw_ostream&) + 221
22 lld 0x0000000108034f99 lld::UniversalDriver::link(llvm::MutableArrayRef<char const*>, llvm::raw_ostream&) + 1081
23 lld 0x0000000107fe960e main + 94
24 libdyld.dylib 0x00007fff98c385ad start + 1

I think it's because lld maybe not a direct replacement for ld. Then I am thinking is it possible to first link multiple object files into a single object file with lld (and do the hacking during this step) using -r option and then do the full link with ld?

So, my question is, is that possible to replace mac ld with lld? If not possible to fully replace it, is that possible to use lld to generate a single intermediate single object file and then input it to ld?

Thanks so much!

asked 3 mins ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 347 تاريخ : شنبه 29 اسفند 1394 ساعت: 20:41