[PATCH] D144095: [BOLT] Fix data reoder for aarch64

Vladislav Khmelevsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 15 05:20:47 PST 2023


yota9 created this revision.
yota9 added reviewers: maksfb, rafauler, Amir.
Herald added subscribers: treapster, ayermolo, kristof.beyls.
Herald added a project: All.
yota9 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Use proper relocation for aarch64


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144095

Files:
  bolt/include/bolt/Core/Relocation.h
  bolt/lib/Core/BinarySection.cpp
  bolt/lib/Core/Relocation.cpp


Index: bolt/lib/Core/Relocation.cpp
===================================================================
--- bolt/lib/Core/Relocation.cpp
+++ bolt/lib/Core/Relocation.cpp
@@ -637,6 +637,12 @@
   return isPCRelativeX86(Type);
 }
 
+uint64_t Relocation::getAbs64() {
+  if (Arch == Triple::aarch64)
+    return ELF::R_AARCH64_ABS64;
+  return ELF::R_X86_64_64;
+}
+
 size_t Relocation::emit(MCStreamer *Streamer) const {
   const size_t Size = getSizeForType(Type);
   MCContext &Ctx = Streamer->getContext();
Index: bolt/lib/Core/BinarySection.cpp
===================================================================
--- bolt/lib/Core/BinarySection.cpp
+++ bolt/lib/Core/BinarySection.cpp
@@ -252,7 +252,7 @@
     // of the reordered segment to force LLVM to recognize and map this
     // section.
     MCSymbol *ZeroSym = BC.registerNameAtAddress("Zero", 0, 0, 0);
-    addRelocation(OS.tell(), ZeroSym, ELF::R_X86_64_64, 0xdeadbeef);
+    addRelocation(OS.tell(), ZeroSym, Relocation::getAbs64(), 0xdeadbeef);
 
     uint64_t Zero = 0;
     OS.write(reinterpret_cast<const char *>(&Zero), sizeof(Zero));
Index: bolt/include/bolt/Core/Relocation.h
===================================================================
--- bolt/include/bolt/Core/Relocation.h
+++ bolt/include/bolt/Core/Relocation.h
@@ -106,6 +106,9 @@
   /// Return code for a PC-relative 8-byte relocation
   static uint64_t getPC64();
 
+  /// Return code for a ABS 8-byte relocation
+  static uint64_t getAbs64();
+
   /// Return true if this relocation is PC-relative. Return false otherwise.
   bool isPCRelative() const { return isPCRelative(Type); }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144095.497644.patch
Type: text/x-patch
Size: 1622 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230215/5d058d1a/attachment.bin>


More information about the llvm-commits mailing list