[lld] [ELF][NFC] Allow non-GotSection for addAddendOnlyRelocIfNonPreemptible (PR #104228)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 13:18:21 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld
Author: Jessica Clarke (jrtc27)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/104228.diff
2 Files Affected:
- (modified) lld/ELF/SyntheticSections.cpp (+3-3)
- (modified) lld/ELF/SyntheticSections.h (+2-1)
``````````diff
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index c27ab2b67dc2b..7d26fa9aea74a 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 d4169e1e1acaf..43eb82cbb3e28 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>
``````````
</details>
https://github.com/llvm/llvm-project/pull/104228
More information about the llvm-commits
mailing list