Skip to content

Conversation

aaupov
Copy link
Contributor

@aaupov aaupov commented May 9, 2024

getSignedValueAtAddress calls DataExtractor::getSigned which naturally
returns a signed value.

Test Plan: NFCI

aaupov added 2 commits May 9, 2024 14:50
Created using spr 1.3.4
@llvmbot
Copy link
Member

llvmbot commented May 9, 2024

@llvm/pr-subscribers-bolt

Author: Amir Ayupov (aaupov)

Changes

getSignedValueAtAddress calls DataExtractor::getSigned which naturally
returns a signed value.

Test Plan: NFCI


Full diff: https://github.com/llvm/llvm-project/pull/91664.diff

3 Files Affected:

  • (modified) bolt/include/bolt/Core/BinaryContext.h (+1-2)
  • (modified) bolt/lib/Core/BinaryContext.cpp (+1-1)
  • (modified) bolt/lib/Rewrite/LinuxKernelRewriter.cpp (+1-1)
diff --git a/bolt/include/bolt/Core/BinaryContext.h b/bolt/include/bolt/Core/BinaryContext.h
index 75765819ac464..4a59a581dfedb 100644
--- a/bolt/include/bolt/Core/BinaryContext.h
+++ b/bolt/include/bolt/Core/BinaryContext.h
@@ -1217,8 +1217,7 @@ class BinaryContext {
 
   /// Return a signed value of \p Size stored at \p Address. The address has
   /// to be a valid statically allocated address for the binary.
-  ErrorOr<uint64_t> getSignedValueAtAddress(uint64_t Address,
-                                            size_t Size) const;
+  ErrorOr<int64_t> getSignedValueAtAddress(uint64_t Address, size_t Size) const;
 
   /// Special case of getUnsignedValueAtAddress() that uses a pointer size.
   ErrorOr<uint64_t> getPointerAtAddress(uint64_t Address) const {
diff --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp
index ad2eb18caf109..507b203ea9d8b 100644
--- a/bolt/lib/Core/BinaryContext.cpp
+++ b/bolt/lib/Core/BinaryContext.cpp
@@ -2212,7 +2212,7 @@ ErrorOr<uint64_t> BinaryContext::getUnsignedValueAtAddress(uint64_t Address,
   return DE.getUnsigned(&ValueOffset, Size);
 }
 
-ErrorOr<uint64_t> BinaryContext::getSignedValueAtAddress(uint64_t Address,
+ErrorOr<int64_t> BinaryContext::getSignedValueAtAddress(uint64_t Address,
                                                          size_t Size) const {
   const ErrorOr<const BinarySection &> Section = getSectionForAddress(Address);
   if (!Section)
diff --git a/bolt/lib/Rewrite/LinuxKernelRewriter.cpp b/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
index 99775ccfe38d3..b2c8b2446f7e1 100644
--- a/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
+++ b/bolt/lib/Rewrite/LinuxKernelRewriter.cpp
@@ -393,7 +393,7 @@ void LinuxKernelRewriter::processLKKSymtab(bool IsGPL) {
 
   for (uint64_t I = 0; I < SectionSize; I += 4) {
     const uint64_t EntryAddress = SectionAddress + I;
-    ErrorOr<uint64_t> Offset = BC.getSignedValueAtAddress(EntryAddress, 4);
+    ErrorOr<int64_t> Offset = BC.getSignedValueAtAddress(EntryAddress, 4);
     assert(Offset && "Reading valid PC-relative offset for a ksymtab entry");
     const int32_t SignedOffset = *Offset;
     const uint64_t RefAddress = EntryAddress + SignedOffset;

Created using spr 1.3.4
Copy link
Contributor

@rafaelauler rafaelauler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@aaupov aaupov changed the base branch from users/aaupov/spr/main.boltnfci-fix-return-type-of-bcgetsignedvalueataddress to main May 24, 2024 22:33
@aaupov aaupov merged commit c460e45 into main May 24, 2024
@aaupov aaupov deleted the users/aaupov/spr/boltnfci-fix-return-type-of-bcgetsignedvalueataddress branch May 24, 2024 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants