This is an archive of the discontinued LLVM Phabricator instance.

[llvm-nm] Add tapi file support
ClosedPublic

Authored by cishida on Aug 13 2019, 1:06 PM.

Details

Summary

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

Diff Detail

Repository
rL LLVM

Event Timeline

cishida created this revision.Aug 13 2019, 1:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2019, 1:06 PM
plotfi added a subscriber: plotfi.Aug 22 2019, 5:27 PM
ributzka added inline comments.Sep 6 2019, 10:48 AM
llvm/tools/llvm-nm/llvm-nm.cpp
342 ↗(On Diff #214905)

We should be able to identify if a slice is 64bit and return a proper value here.

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?

cishida updated this revision to Diff 219549.Sep 10 2019, 8:17 AM

Add 64bit symbol reading

cishida marked an inline comment as done.Sep 10 2019, 8:19 AM

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.

llvm/lib/TextAPI/MachO/Architecture.cpp
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.

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.

cishida updated this revision to Diff 219592.Sep 10 2019, 1:07 PM
  • [TextAPI] move archs to architecture.def
  1. Updating D66160: [llvm-nm] Add tapi file support #

move the set of 64bit supported archs inside the def file

cishida updated this revision to Diff 219609.Sep 10 2019, 2:41 PM

[TextAPI] add num bits to architecture

This revision is now accepted and ready to land.Sep 10 2019, 3:02 PM
This revision was automatically updated to reflect the committed changes.
kcc added a subscriber: kcc.Sep 11 2019, 2:01 PM

Hi.

The asan bot is unhappy:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/35078/steps/check-llvm%20asan/logs/stdio

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)
In D66160#1666925, @kcc wrote:

Hi.

The asan bot is unhappy:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/35078/steps/check-llvm%20asan/logs/stdio

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)

Reverted and investigating. Sorry about that, and thanks for bringing it up.