[PATCH] D127413: [BOLT][AARCH64] Skip R_AARCH64_LD_PREL_LO19 relocation

Vladislav Khmelevsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 9 09:05:59 PDT 2022


yota9 created this revision.
yota9 added reviewers: maksfb, rafauler, Amir.
Herald added subscribers: 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.

Supress failed to analyze relocations warning for R_AARCH64_LD_PREL_LO19
relocation. This relocation is mostly used to get value stored in CI and
we don't process it since we are caluclating target address using the
instruction value in evaluateMemOperandTarget().


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127413

Files:
  bolt/include/bolt/Core/Relocation.h
  bolt/lib/Core/Relocation.cpp
  bolt/lib/Rewrite/RewriteInstance.cpp


Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -2332,7 +2332,7 @@
     SmallString<16> TypeName;
     Rel.getTypeName(TypeName);
     uint64_t RType = Rel.getType();
-    if (Relocation::isNone(RType))
+    if (Relocation::skipRelocationType(RType))
       continue;
 
     // Adjust the relocation type as the linker might have skewed it.
Index: bolt/lib/Core/Relocation.cpp
===================================================================
--- bolt/lib/Core/Relocation.cpp
+++ bolt/lib/Core/Relocation.cpp
@@ -165,6 +165,12 @@
   }
 }
 
+bool skipRelocationTypeX86(uint64_t Type) { return Type == ELF::R_X86_64_NONE; }
+
+bool skipRelocationTypeAArch64(uint64_t Type) {
+  return Type == ELF::R_AARCH64_NONE || Type == ELF::R_AARCH64_LD_PREL_LO19;
+}
+
 bool skipRelocationProcessX86(uint64_t Type, uint64_t Contents) {
   return false;
 }
@@ -536,6 +542,12 @@
   return getSizeForTypeX86(Type);
 }
 
+bool Relocation::skipRelocationType(uint64_t Type) {
+  if (Arch == Triple::aarch64)
+    return skipRelocationTypeAArch64(Type);
+  return skipRelocationTypeX86(Type);
+}
+
 bool Relocation::skipRelocationProcess(uint64_t Type, uint64_t Contents) {
   if (Arch == Triple::aarch64)
     return skipRelocationProcessAArch64(Type, Contents);
Index: bolt/include/bolt/Core/Relocation.h
===================================================================
--- bolt/include/bolt/Core/Relocation.h
+++ bolt/include/bolt/Core/Relocation.h
@@ -55,7 +55,10 @@
   /// Return size of this relocation.
   size_t getSize() const { return getSizeForType(Type); }
 
-  /// Handle special cases when relocation should not be processed by bolt
+  /// Skip relocations that we don't want to handle by BOLT
+  static bool skipRelocationType(uint64_t Type);
+
+  /// Handle special cases when relocation should not be processed by BOLT
   static bool skipRelocationProcess(uint64_t Type, uint64_t Contents);
 
   // Adjust value depending on relocation type (make it PC relative or not)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127413.435584.patch
Type: text/x-patch
Size: 2122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220609/1ca00a7b/attachment.bin>


More information about the llvm-commits mailing list