Skip to content

Commit

Permalink
[ELF][NFC] Allow non-GotSection for addAddendOnlyRelocIfNonPreemptible (
Browse files Browse the repository at this point in the history
llvm#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.
  • Loading branch information
jrtc27 authored Aug 15, 2024
1 parent aca01bf commit bd47ba7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lld/ELF/SyntheticSections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion lld/ELF/SyntheticSections.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit bd47ba7

Please sign in to comment.