[PATCH] D130073: [BOLT] Handle broken .dynsym in stripped binaries
Huan Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 19 03:50:23 PDT 2022
nhuhuan created this revision.
Herald added a reviewer: rafauler.
Herald added a subscriber: ayermolo.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
nhuhuan requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
Strip tools cause a few symbols in .dynsym to have bad section index.
This update safely keeps such broken symbols intact.
Test Plan:
ninja check-bolt
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D130073
Files:
bolt/lib/Rewrite/RewriteInstance.cpp
Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -4490,6 +4490,14 @@
std::vector<ELFSymTy> Symbols;
auto getNewSectionIndex = [&](uint32_t OldIndex) {
+ // For dynamic symbol table, the section index could be wrong on the input,
+ // and its value is ignored by the runtime if it's different from
+ // SHN_UNDEF and SHN_ABS.
+ // However, we still need to update dynamic symbol table, so return a
+ // section index, even though the index is broken.
+ if (IsDynSym && OldIndex >= NewSectionIndex.size())
+ return OldIndex;
+
assert(OldIndex < NewSectionIndex.size() && "section index out of bounds");
const uint32_t NewIndex = NewSectionIndex[OldIndex];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130073.445769.patch
Type: text/x-patch
Size: 845 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220719/235b68de/attachment.bin>
More information about the llvm-commits
mailing list