The gold linker veneers are written between functions without symbols,
so we to handle it specially in BOLT.
Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei
Paths
| Differential D129260
[BOLT][AArch64] Handle gold linker veneers ClosedPublic Authored by yota9 on Jul 7 2022, 1:15 AM.
Details Summary The gold linker veneers are written between functions without symbols, Vladislav Khmelevsky,
Diff Detail
Event TimelineComment Actions @rafauler I've add isIgnored check, could you please verify that everything is OK now? Comment Actions There's a memory leak the two tests:
This is detected by just running our regular test suite, but with bolt built with address sanitizer from llvm. If you are using cmake, just add -DLLVM_USE_SANITIZER=Address if you are building bolt with clang. Here's the leak stack trace: 74287==ERROR: LeakSanitizer: detected memory leaksDirect leak of 176 byte(s) in 2 object(s) allocated from: #0 in operator new(unsigned long) (build/bin/llvm-bolt+0x769ce7) #1 in llvm::bolt::BinaryContext::registerNameAtAddress(llvm::StringRef, unsigned long, unsigned long, unsigned short, unsigned int) /bolt/lib/Core/BinaryContext.cpp:985:10 #2 in llvm::bolt::BinaryContext::getOrCreateGlobalSymbol(unsigned long, llvm::Twine, unsigned long, unsigned short, unsigned int) /bolt/lib/Core/BinaryContext.cpp:743:10 #3 in operator() /bolt/lib/Core/BinaryFunction.cpp:1095:23 #4 in llvm::bolt::BinaryFunction::disassemble() /bolt/lib/Core/BinaryFunction.cpp:1300:28 #5 in llvm::bolt::RewriteInstance::disassembleFunctions() /bolt/lib/Rewrite/RewriteInstance.cpp:2836:19 #6 in llvm::bolt::RewriteInstance::run() /bolt/lib/Rewrite/RewriteInstance.cpp:747:3 #7 in main /bolt/tools/driver/llvm-bolt.cpp:244:24 #8 in __libc_start_main #9 in _start Indirect leak of 16 byte(s) in 2 object(s) allocated from: #0 in operator new(unsigned long) #1 in allocate #2 in allocate #3 in _M_allocate #4 in _M_realloc_insert<llvm::MCSymbol *> #5 in emplace_back<llvm::MCSymbol *> #6 in push_back / #7 in llvm::bolt::BinaryData::BinaryData(llvm::MCSymbol&, unsigned long, unsigned long, unsigned short, llvm::bolt::BinarySection&, unsigned int) /bolt/lib/Core/BinaryData.cpp:136:11 #8 in llvm::bolt::BinaryContext::registerNameAtAddress(llvm::StringRef, unsigned long, unsigned long, unsigned short, unsigned int) /bolt/lib/Core/BinaryContext.cpp:985:14 #9 in llvm::bolt::BinaryContext::getOrCreateGlobalSymbol(unsigned long, llvm::Twine, unsigned long, unsigned short, unsigned int) /bolt/lib/Core/BinaryContext.cpp:743:10 #10 in operator() /bolt/lib/Core/BinaryFunction.cpp:1095:23 #11 in llvm::bolt::BinaryFunction::disassemble() /bolt/lib/Core/BinaryFunction.cpp:1300:28 #12 in llvm::bolt::RewriteInstance::disassembleFunctions() /bolt/lib/Rewrite/RewriteInstance.cpp:2836:19 #13 in llvm::bolt::RewriteInstance::run() /bolt/lib/Rewrite/RewriteInstance.cpp:747:3 #14 in main /bolt/tools/driver/llvm-bolt.cpp:244:24 #15 in __libc_start_main #16 in _start
Comment Actions @rafauler I'll try to check the cause of memory leak, probably it is connected to the VeneerElimination pass, since it is unusual case to create the new functions after disassemble but also remove them during passes, probably something is not handled properly..
Comment Actions @rafauler Thanks for sanitizer logs! Although I didn't try it my self, but I've checked them and as I said it was a problem in veneer elimination pass, which was not delete the allocated binarydata struct previously. Now everything should be fine :) Comment Actions @rafauler I've decided to go with isPseudo() for veneers, I don't think that the pass is an appropriate place to remove functions/symbols. + A bit of code refactoring in pass :) This revision is now accepted and ready to land.Jul 12 2022, 12:31 PM Closed by commit rG35efe1d80635: [BOLT][AArch64] Handle gold linker veneers (authored by yota9). · Explain WhyJul 13 2022, 4:48 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 444223 bolt/include/bolt/Core/BinaryContext.h
bolt/include/bolt/Core/BinaryFunction.h
bolt/include/bolt/Core/MCPlusBuilder.h
bolt/lib/Core/BinaryContext.cpp
bolt/lib/Core/BinaryFunction.cpp
bolt/lib/Passes/BinaryPasses.cpp
bolt/lib/Passes/VeneerElimination.cpp
bolt/lib/Rewrite/BinaryPassManager.cpp
bolt/lib/Rewrite/RewriteInstance.cpp
bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
bolt/test/AArch64/veneer-gold.s
bolt/test/AArch64/veneer.s
|
nit: I suspect btw that a regular "std::vector" makes more sense here (since you're not doing any operation that would be faster with a linked list)