[PATCH] D150335: [BOLT] Fix flush pending relocs

Rafael Auler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 10 18:03:19 PDT 2023


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

https://github.com/facebookincubator/BOLT/pull/255 accidentally
omitted a relocation type when refactoring the code. Add this type back
and change function name so its intent is more clear.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150335

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
@@ -262,10 +262,11 @@
   return false;
 }
 
-static uint64_t adjustValueX86(uint64_t Type, uint64_t Value, uint64_t PC) {
+static uint64_t encodeValueX86(uint64_t Type, uint64_t Value, uint64_t PC) {
   switch (Type) {
   default:
-    llvm_unreachable("not supported relocation");
+    llvm_unreachable("unsupported relocation");
+  case ELF::R_X86_64_64:
   case ELF::R_X86_64_32:
     break;
   case ELF::R_X86_64_PC32:
@@ -275,10 +276,10 @@
   return Value;
 }
 
-static uint64_t adjustValueAArch64(uint64_t Type, uint64_t Value, uint64_t PC) {
+static uint64_t encodeValueAArch64(uint64_t Type, uint64_t Value, uint64_t PC) {
   switch (Type) {
   default:
-    llvm_unreachable("not supported relocation");
+    llvm_unreachable("unsupported relocation");
   case ELF::R_AARCH64_ABS32:
     break;
   case ELF::R_AARCH64_PREL16:
@@ -566,11 +567,11 @@
   return skipRelocationProcessX86(Type, Contents);
 }
 
-uint64_t Relocation::adjustValue(uint64_t Type, uint64_t Value,
+uint64_t Relocation::encodeValue(uint64_t Type, uint64_t Value,
                                  uint64_t PC) {
   if (Arch == Triple::aarch64)
-    return adjustValueAArch64(Type, Value, PC);
-  return adjustValueX86(Type, Value, PC);
+    return encodeValueAArch64(Type, Value, PC);
+  return encodeValueX86(Type, Value, PC);
 }
 
 uint64_t Relocation::extractValue(uint64_t Type, uint64_t Contents,
Index: bolt/lib/Core/BinarySection.cpp
===================================================================
--- bolt/lib/Core/BinarySection.cpp
+++ bolt/lib/Core/BinarySection.cpp
@@ -146,7 +146,7 @@
     if (Reloc.Symbol)
       Value += Resolver(Reloc.Symbol);
 
-    Value = Relocation::adjustValue(Reloc.Type, Value,
+    Value = Relocation::encodeValue(Reloc.Type, Value,
                                     SectionAddress + Reloc.Offset);
 
     OS.pwrite(reinterpret_cast<const char *>(&Value),
Index: bolt/include/bolt/Core/Relocation.h
===================================================================
--- bolt/include/bolt/Core/Relocation.h
+++ bolt/include/bolt/Core/Relocation.h
@@ -64,8 +64,7 @@
   static bool skipRelocationProcess(uint64_t &Type, uint64_t Contents);
 
   // Adjust value depending on relocation type (make it PC relative or not)
-  static uint64_t adjustValue(uint64_t Type, uint64_t Value,
-                              uint64_t PC);
+  static uint64_t encodeValue(uint64_t Type, uint64_t Value, uint64_t PC);
 
   /// Extract current relocated value from binary contents. This is used for
   /// RISC architectures where values are encoded in specific bits depending


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150335.521187.patch
Type: text/x-patch
Size: 2757 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230511/97dc9b4c/attachment.bin>


More information about the llvm-commits mailing list