Skip to content

Commit bd47ba7

Browse files
authored
[ELF][NFC] Allow non-GotSection for addAddendOnlyRelocIfNonPreemptible (#104228)
This was done as an afterthought in c3c9e45 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 c3c9e45.
1 parent aca01bf commit bd47ba7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lld/ELF/SyntheticSections.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,14 +1639,14 @@ void RelocationBaseSection::addSymbolReloc(
16391639
}
16401640

16411641
void RelocationBaseSection::addAddendOnlyRelocIfNonPreemptible(
1642-
RelType dynType, GotSection &sec, uint64_t offsetInSec, Symbol &sym,
1642+
RelType dynType, InputSectionBase &isec, uint64_t offsetInSec, Symbol &sym,
16431643
RelType addendRelType) {
16441644
// No need to write an addend to the section for preemptible symbols.
16451645
if (sym.isPreemptible)
1646-
addReloc({dynType, &sec, offsetInSec, DynamicReloc::AgainstSymbol, sym, 0,
1646+
addReloc({dynType, &isec, offsetInSec, DynamicReloc::AgainstSymbol, sym, 0,
16471647
R_ABS});
16481648
else
1649-
addReloc(DynamicReloc::AddendOnlyWithTargetVA, dynType, sec, offsetInSec,
1649+
addReloc(DynamicReloc::AddendOnlyWithTargetVA, dynType, isec, offsetInSec,
16501650
sym, 0, R_ABS, addendRelType);
16511651
}
16521652

lld/ELF/SyntheticSections.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ class RelocationBaseSection : public SyntheticSection {
523523
}
524524
/// Add a dynamic relocation using the target address of \p sym as the addend
525525
/// if \p sym is non-preemptible. Otherwise add a relocation against \p sym.
526-
void addAddendOnlyRelocIfNonPreemptible(RelType dynType, GotSection &sec,
526+
void addAddendOnlyRelocIfNonPreemptible(RelType dynType,
527+
InputSectionBase &isec,
527528
uint64_t offsetInSec, Symbol &sym,
528529
RelType addendRelType);
529530
template <bool shard = false>

0 commit comments

Comments
 (0)