This commit is the final one for adding tapi support to the llvm-nm implementation.
This commit also has accompanying tests the additions to lib/Object
Does this addition mean that llvm-nm should eventually include some support for other text formats like ifs/elfabi etc? I think this could be pretty useful for writing tests, which I assume is part of the motivation here?
From what I understand about the elfabi tool is that it just produces tbe's from ELF object files, I don't actually know how its being used for linking currently, so I don't know the full picture to reason adding nm support for it.
As far as tbd support, cross checking is definitely a nice perk of this support . @ributzka can add better context than I could.
The motivation to add this to llvm-nm, is to get the same functionally back that we lost with adding TBD files. Using it for testing is a nice side benefit.
|73 ↗||(On Diff #219549)|
I would prefer if we added this information to Architecture.def and then use it here. That way the code will not get out-of-sync when someone adds a new architecture slice.
Ah I get it, because ld64 is tbd-aware the end product is the text. I’m still not sure if I will add any support to lld for something like ifs, things still seem good just using the ifs text format for the intermediate symbol merging.
Please fix or revert ASAP.
10406==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 312 byte(s) in 1 object(s) allocated from:
#0 0x514d38 in operator new(unsigned long) /b/sanitizer-x86_64-linux-fast/build/llvm-project/compiler-rt/lib/asan/asan_new_delete.cc:105 #1 0x15627c9 in llvm::yaml::MappingTraits<llvm::MachO::InterfaceFile const*>::NormalizedTBD::denormalize(llvm::yaml::IO&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/TextAPI/MachO/TextStub.cpp:403:20 #2 0x1548510 in ~MappingNormalization /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:1321:24 #3 0x1548510 in llvm::yaml::MappingTraits<llvm::MachO::InterfaceFile const*>::mapping(llvm::yaml::IO&, llvm::MachO::InterfaceFile const*&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/TextAPI/MachO/TextStub.cpp:592 #4 0x1542bbe in doMapping<const llvm::MachO::InterfaceFile *> /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:961:3 #5 0x1542bbe in yamlize<const llvm::MachO::InterfaceFile *, llvm::yaml::EmptyContext> /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:1085 #6 0x1542bbe in operator>><std::__1::vector<const llvm::MachO::InterfaceFile *, std::__1::allocator<const llvm::MachO::InterfaceFile *> > > /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/YAMLTraits.h:1696 #7 0x1542bbe in llvm::MachO::TextAPIReader::get(llvm::MemoryBufferRef) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/TextAPI/MachO/TextStub.cpp:633 #8 0x139fd27 in llvm::object::TapiUniversal::TapiUniversal(llvm::MemoryBufferRef, llvm::Error&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Object/TapiUniversal.cpp:25:17 #9 0x13a0b0d in llvm::object::TapiUniversal::create(llvm::MemoryBufferRef) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Object/TapiUniversal.cpp:50:42 #10 0x122d5e9 in llvm::object::createBinary(llvm::MemoryBufferRef, llvm::LLVMContext*) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Object/Binary.cpp:91:12 #11 0x51cf7c in dumpSymbolNamesFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/llvm-nm/llvm-nm.cpp:1795:7 #12 0x51bbf7 in for_each<std::__1::__wrap_iter<std::__1::basic_string<char> *>, void (*)(std::__1::basic_string<char> &)> /b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/algorithm:886:9 #13 0x51bbf7 in for_each<llvm::cl::list<std::__1::basic_string<char>, bool, llvm::cl::parser<std::string> > &, void (*)(std::__1::basic_string<char> &)> /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/STLExtras.h:1159 #14 0x51bbf7 in main /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/llvm-nm/llvm-nm.cpp:2163 #15 0x7f08c0c232e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)