[llvm] 8553faf - [MC] Remove ELFObjectWriter::fixSymbolsInTLSFixups

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 22 20:10:35 PDT 2025


Author: Fangrui Song
Date: 2025-03-22T20:10:31-07:00
New Revision: 8553fafff0f3ee9576fe6ff02d63f6e3197ca010

URL: https://github.com/llvm/llvm-project/commit/8553fafff0f3ee9576fe6ff02d63f6e3197ca010
DIFF: https://github.com/llvm/llvm-project/commit/8553fafff0f3ee9576fe6ff02d63f6e3197ca010.diff

LOG: [MC] Remove ELFObjectWriter::fixSymbolsInTLSFixups

Finish the migration started by
eea7d32bd262bb5f61790c42ebaa147aa26c3979.
STT_TLS setting has been moved to backend getRelocType.
75f5a4f0dc7d96134cca86543ef3f86ef218ce77 migrated the last target, VE.

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCELFObjectWriter.h
    llvm/lib/MC/ELFObjectWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCELFObjectWriter.h b/llvm/include/llvm/MC/MCELFObjectWriter.h
index a61abd58e8358..3b7a0c8a70257 100644
--- a/llvm/include/llvm/MC/MCELFObjectWriter.h
+++ b/llvm/include/llvm/MC/MCELFObjectWriter.h
@@ -189,8 +189,6 @@ class ELFObjectWriter final : public MCObjectWriter {
   bool checkRelocation(MCContext &Ctx, SMLoc Loc, const MCSectionELF *From,
                        const MCSectionELF *To);
 
-  void fixSymbolsInTLSFixups(MCAssembler &Asm, const MCExpr *Expr);
-
   unsigned getELFHeaderEFlags() const { return ELFHeaderEFlags; }
   void setELFHeaderEFlags(unsigned Flags) { ELFHeaderEFlags = Flags; }
 

diff  --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index ef600ded3b077..6fb67e63d5d0a 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1464,9 +1464,6 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
     return;
   }
 
-  if (Fixup.getValue())
-    fixSymbolsInTLSFixups(Asm, Fixup.getValue());
-
   const MCSymbolELF *RenamedSymA = SymA;
   if (SymA) {
     if (const MCSymbolELF *R = Renames.lookup(SymA))
@@ -1501,45 +1498,6 @@ bool ELFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
   return &SymA.getSection() == FB.getParent();
 }
 
-void ELFObjectWriter::fixSymbolsInTLSFixups(MCAssembler &Asm,
-                                            const MCExpr *expr) {
-  switch (expr->getKind()) {
-  case MCExpr::Target:
-    cast<MCTargetExpr>(expr)->fixELFSymbolsInTLSFixups(Asm);
-    break;
-  case MCExpr::Constant:
-    break;
-
-  case MCExpr::Binary: {
-    const MCBinaryExpr *be = cast<MCBinaryExpr>(expr);
-    fixSymbolsInTLSFixups(Asm, be->getLHS());
-    fixSymbolsInTLSFixups(Asm, be->getRHS());
-    break;
-  }
-
-  case MCExpr::SymbolRef: {
-    const MCSymbolRefExpr &symRef = *cast<MCSymbolRefExpr>(expr);
-    switch (symRef.getKind()) {
-    default:
-      return;
-    case MCSymbolRefExpr::VK_GOTTPOFF:
-    case MCSymbolRefExpr::VK_TLSGD:
-    case MCSymbolRefExpr::VK_TLSLD:
-    case MCSymbolRefExpr::VK_TLSLDM:
-    case MCSymbolRefExpr::VK_TPOFF:
-      break;
-    }
-    Asm.registerSymbol(symRef.getSymbol());
-    cast<MCSymbolELF>(symRef.getSymbol()).setType(ELF::STT_TLS);
-    break;
-  }
-
-  case MCExpr::Unary:
-    fixSymbolsInTLSFixups(Asm, cast<MCUnaryExpr>(expr)->getSubExpr());
-    break;
-  }
-}
-
 uint64_t ELFObjectWriter::writeObject(MCAssembler &Asm) {
   uint64_t Size =
       ELFWriter(*this, OS, IsLittleEndian,


        


More information about the llvm-commits mailing list