[PATCH] D131812: [BOLT][NFC] Move printRelocationInfo into a method
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 17 16:21:19 PDT 2022
Amir updated this revision to Diff 453468.
Amir added a comment.
clang-format
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131812/new/
https://reviews.llvm.org/D131812
Files:
bolt/include/bolt/Rewrite/RewriteInstance.h
bolt/lib/Rewrite/RewriteInstance.cpp
Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -2264,6 +2264,30 @@
}
}
+void RewriteInstance::printRelocationInfo(const RelocationRef &Rel,
+ StringRef SymbolName,
+ uint64_t SymbolAddress,
+ uint64_t Addend,
+ uint64_t ExtractedValue) const {
+ SmallString<16> TypeName;
+ Rel.getTypeName(TypeName);
+ const uint64_t Address = SymbolAddress + Addend;
+ const uint64_t Offset = Rel.getOffset();
+ ErrorOr<BinarySection &> Section = BC->getSectionForAddress(SymbolAddress);
+ BinaryFunction *Func =
+ BC->getBinaryFunctionContainingAddress(Offset, false, BC->isAArch64());
+ dbgs() << formatv("Relocation: offset = {0:x}; type = {1}; value = {2:x}; ",
+ Offset, TypeName, ExtractedValue)
+ << formatv("symbol = {0} ({1}); symbol address = {2:x}; ", SymbolName,
+ Section ? Section->getName() : "", SymbolAddress)
+ << formatv("addend = {0:x}; address = {1:x}; in = ", Addend, Address);
+ if (Func)
+ dbgs() << Func->getPrintName();
+ else
+ dbgs() << BC->getSectionForAddress(Rel.getOffset())->getName();
+ dbgs() << '\n';
+}
+
void RewriteInstance::readRelocations(const SectionRef &Section) {
LLVM_DEBUG({
StringRef SectionName = cantFail(Section.getName());
@@ -2300,32 +2324,6 @@
const bool IsAArch64 = BC->isAArch64();
const bool IsFromCode = RelocatedSection.isText();
- auto printRelocationInfo = [&](const RelocationRef &Rel,
- StringRef SymbolName,
- uint64_t SymbolAddress,
- uint64_t Addend,
- uint64_t ExtractedValue) {
- SmallString<16> TypeName;
- Rel.getTypeName(TypeName);
- const uint64_t Address = SymbolAddress + Addend;
- ErrorOr<BinarySection &> Section = BC->getSectionForAddress(SymbolAddress);
- dbgs() << "Relocation: offset = 0x"
- << Twine::utohexstr(Rel.getOffset())
- << "; type = " << TypeName
- << "; value = 0x" << Twine::utohexstr(ExtractedValue)
- << "; symbol = " << SymbolName
- << " (" << (Section ? Section->getName() : "") << ")"
- << "; symbol address = 0x" << Twine::utohexstr(SymbolAddress)
- << "; addend = 0x" << Twine::utohexstr(Addend)
- << "; address = 0x" << Twine::utohexstr(Address)
- << "; in = ";
- if (BinaryFunction *Func = BC->getBinaryFunctionContainingAddress(
- Rel.getOffset(), false, IsAArch64))
- dbgs() << Func->getPrintName() << "\n";
- else
- dbgs() << BC->getSectionForAddress(Rel.getOffset())->getName() << "\n";
- };
-
for (const RelocationRef &Rel : Section.relocations()) {
SmallString<16> TypeName;
Rel.getTypeName(TypeName);
Index: bolt/include/bolt/Rewrite/RewriteInstance.h
===================================================================
--- bolt/include/bolt/Rewrite/RewriteInstance.h
+++ bolt/include/bolt/Rewrite/RewriteInstance.h
@@ -134,6 +134,11 @@
/// Read relocations from a given section.
void readDynamicRelocations(const object::SectionRef &Section, bool IsJmpRel);
+ /// Print relocation information.
+ void printRelocationInfo(const RelocationRef &Rel, StringRef SymbolName,
+ uint64_t SymbolAddress, uint64_t Addend,
+ uint64_t ExtractedValue) const;
+
/// Read relocations from a given section.
void readRelocations(const object::SectionRef &Section);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131812.453468.patch
Type: text/x-patch
Size: 3800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220817/14cd7bf8/attachment.bin>
More information about the llvm-commits
mailing list