[llvm] 872e4a3 - [X86] Replace reloc_global_offset_table8 with R_X86_64_GOTPC64

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 1 13:32:53 PST 2025


Author: Fangrui Song
Date: 2025-03-01T13:32:48-08:00
New Revision: 872e4a33884b56384ca1ac92aed135bb0d9cc280

URL: https://github.com/llvm/llvm-project/commit/872e4a33884b56384ca1ac92aed135bb0d9cc280
DIFF: https://github.com/llvm/llvm-project/commit/872e4a33884b56384ca1ac92aed135bb0d9cc280.diff

LOG: [X86] Replace reloc_global_offset_table8 with R_X86_64_GOTPC64

Added: 
    

Modified: 
    llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
    llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
    llvm/lib/Target/X86/MCTargetDesc/X86FixupKinds.h
    llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
index e234d320b2a19..1985973c9f5f5 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -638,7 +638,6 @@ const MCFixupKindInfo &X86AsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
       {"reloc_signed_4byte", 0, 32, 0},
       {"reloc_signed_4byte_relax", 0, 32, 0},
       {"reloc_global_offset_table", 0, 32, 0},
-      {"reloc_global_offset_table8", 0, 64, 0},
       {"reloc_branch_4byte_pcrel", 0, 32, MCFixupKindInfo::FKF_IsPCRel},
       // clang-format on
   };
@@ -696,7 +695,6 @@ static unsigned getFixupKindSize(unsigned Kind) {
   case FK_PCRel_8:
   case FK_SecRel_8:
   case FK_Data_8:
-  case X86::reloc_global_offset_table8:
     return 8;
   }
 }

diff  --git a/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
index cc712055a8615..927a566f8c2bf 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
@@ -54,10 +54,6 @@ static X86_64RelType getType64(MCFixupKind Kind,
     llvm_unreachable("Unimplemented");
   case FK_NONE:
     return RT64_NONE;
-  case X86::reloc_global_offset_table8:
-    Modifier = MCSymbolRefExpr::VK_GOT;
-    IsPCRel = true;
-    return RT64_64;
   case FK_Data_8:
     return RT64_64;
   case X86::reloc_signed_4byte:

diff  --git a/llvm/lib/Target/X86/MCTargetDesc/X86FixupKinds.h b/llvm/lib/Target/X86/MCTargetDesc/X86FixupKinds.h
index 9b951973ab194..e805010869d7b 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86FixupKinds.h
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86FixupKinds.h
@@ -35,7 +35,6 @@ enum Fixups {
   reloc_global_offset_table,                 // 32-bit, relative to the start
                                              // of the instruction. Used only
                                              // for _GLOBAL_OFFSET_TABLE_.
-  reloc_global_offset_table8,                // 64-bit variant.
   reloc_branch_4byte_pcrel,                  // 32-bit PC relative branch.
   // Marker
   LastTargetFixupKind,

diff  --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
index 55fb9f54c5397..b6ed43b90c4aa 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
@@ -14,6 +14,7 @@
 #include "MCTargetDesc/X86FixupKinds.h"
 #include "MCTargetDesc/X86MCTargetDesc.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/BinaryFormat/ELF.h"
 #include "llvm/MC/MCCodeEmitter.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCExpr.h"
@@ -542,7 +543,8 @@ void X86MCCodeEmitter::emitImmediate(const MCOperand &DispOp, SMLoc Loc,
       assert(ImmOffset == 0);
 
       if (Size == 8) {
-        FixupKind = MCFixupKind(X86::reloc_global_offset_table8);
+        FixupKind =
+            MCFixupKind(FirstLiteralRelocationKind + ELF::R_X86_64_GOTPC64);
       } else {
         assert(Size == 4);
         FixupKind = MCFixupKind(X86::reloc_global_offset_table);


        


More information about the llvm-commits mailing list