[lld] bd47ba7 - [ELF][NFC] Allow non-GotSection for addAddendOnlyRelocIfNonPreemptible (#104228)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 14 18:50:09 PDT 2024


Author: Jessica Clarke
Date: 2024-08-15T02:50:07+01:00
New Revision: bd47ba705607033c3dab0037a8d64159b58bedb4

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

LOG: [ELF][NFC] Allow non-GotSection for addAddendOnlyRelocIfNonPreemptible (#104228)

This was done as an afterthought in c3c9e4531287 without justification.
Nothing relies on it being a specific kind of section, and downstream in
CHERI LLVM we pass a non-GotSection to this function. Thus revert this
overly-restrictive change and allow downstreams to pass other section
types again.

This partially reverts commit c3c9e45312874ff890723f54cabfd41e43b2dbc4.

Added: 
    

Modified: 
    lld/ELF/SyntheticSections.cpp
    lld/ELF/SyntheticSections.h

Removed: 
    


################################################################################
diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index c27ab2b67dc2b2..7d26fa9aea74ab 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -1639,14 +1639,14 @@ void RelocationBaseSection::addSymbolReloc(
 }
 
 void RelocationBaseSection::addAddendOnlyRelocIfNonPreemptible(
-    RelType dynType, GotSection &sec, uint64_t offsetInSec, Symbol &sym,
+    RelType dynType, InputSectionBase &isec, uint64_t offsetInSec, Symbol &sym,
     RelType addendRelType) {
   // No need to write an addend to the section for preemptible symbols.
   if (sym.isPreemptible)
-    addReloc({dynType, &sec, offsetInSec, DynamicReloc::AgainstSymbol, sym, 0,
+    addReloc({dynType, &isec, offsetInSec, DynamicReloc::AgainstSymbol, sym, 0,
               R_ABS});
   else
-    addReloc(DynamicReloc::AddendOnlyWithTargetVA, dynType, sec, offsetInSec,
+    addReloc(DynamicReloc::AddendOnlyWithTargetVA, dynType, isec, offsetInSec,
              sym, 0, R_ABS, addendRelType);
 }
 

diff  --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index d4169e1e1acaf6..43eb82cbb3e28b 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -523,7 +523,8 @@ class RelocationBaseSection : public SyntheticSection {
   }
   /// Add a dynamic relocation using the target address of \p sym as the addend
   /// if \p sym is non-preemptible. Otherwise add a relocation against \p sym.
-  void addAddendOnlyRelocIfNonPreemptible(RelType dynType, GotSection &sec,
+  void addAddendOnlyRelocIfNonPreemptible(RelType dynType,
+                                          InputSectionBase &isec,
                                           uint64_t offsetInSec, Symbol &sym,
                                           RelType addendRelType);
   template <bool shard = false>


        


More information about the llvm-commits mailing list