[llvm] [BOLT] Determine address size from binary (PR #74870)
Nathan Sidwell via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 8 09:51:59 PST 2023
https://github.com/urnathan updated https://github.com/llvm/llvm-project/pull/74870
>From f0e3b3eb895d5301f945743cadb75054f1783815 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell <nathan at acm.org>
Date: Fri, 8 Dec 2023 12:13:31 -0500
Subject: [PATCH 1/2] [BOLT] Determine address size from binary
Don't hard code 64-bit address size.
---
bolt/lib/Core/Exceptions.cpp | 3 ++-
bolt/lib/Rewrite/RewriteInstance.cpp | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/bolt/lib/Core/Exceptions.cpp b/bolt/lib/Core/Exceptions.cpp
index 993f3a7770aa81..ab1885f6bb5851 100644
--- a/bolt/lib/Core/Exceptions.cpp
+++ b/bolt/lib/Core/Exceptions.cpp
@@ -108,7 +108,8 @@ void BinaryFunction::parseLSDA(ArrayRef<uint8_t> LSDASectionData,
DWARFDataExtractor Data(
StringRef(reinterpret_cast<const char *>(LSDASectionData.data()),
LSDASectionData.size()),
- BC.DwCtx->getDWARFObj().isLittleEndian(), 8);
+ BC.DwCtx->getDWARFObj().isLittleEndian(),
+ BC.DwCtx->getDWARFObj().getAddressSize());
uint64_t Offset = getLSDAAddress() - LSDASectionAddress;
assert(Data.isValidOffset(Offset) && "wrong LSDA address");
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 8cda0b7fcca9f8..2a8a8b2a16bc40 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -623,7 +623,9 @@ void RewriteInstance::parseBuildID() {
// Reading notes section (see Portable Formats Specification, Version 1.1,
// pg 2-5, section "Note Section").
- DataExtractor DE = DataExtractor(Buf, true, 8);
+ DataExtractor DE = DataExtractor(Buf,
+ /*IsLittleEndian=*/true,
+ InputFile->getBytesInAddress());
uint64_t Offset = 0;
if (!DE.isValidOffset(Offset))
return;
>From d0c178d75cb31819a5c9bb0a461849d01cfafcd8 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell <nathan at acm.org>
Date: Fri, 8 Dec 2023 12:51:47 -0500
Subject: [PATCH 2/2] formatting, (sigh)
---
bolt/lib/Rewrite/RewriteInstance.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 2a8a8b2a16bc40..1e8ca569682f71 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -623,9 +623,9 @@ void RewriteInstance::parseBuildID() {
// Reading notes section (see Portable Formats Specification, Version 1.1,
// pg 2-5, section "Note Section").
- DataExtractor DE = DataExtractor(Buf,
- /*IsLittleEndian=*/true,
- InputFile->getBytesInAddress());
+ DataExtractor DE =
+ DataExtractor(Buf,
+ /*IsLittleEndian=*/true, InputFile->getBytesInAddress());
uint64_t Offset = 0;
if (!DE.isValidOffset(Offset))
return;
More information about the llvm-commits
mailing list