From bd47ba705607033c3dab0037a8d64159b58bedb4 Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Thu, 15 Aug 2024 02:50:07 +0100 Subject: [PATCH] [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. --- lld/ELF/SyntheticSections.cpp | 6 +++--- lld/ELF/SyntheticSections.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) 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