Skip to content

Commit 8511366

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.5 [skip ci]
1 parent e82f5f1 commit 8511366

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lld/ELF/SyntheticSections.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,8 @@ uint64_t DynamicReloc::getOffset() const {
16471647

16481648
int64_t DynamicReloc::computeAddend(Ctx &ctx) const {
16491649
switch (kind) {
1650+
case Computed:
1651+
llvm_unreachable("addend already computed");
16501652
case AddendOnly:
16511653
case AgainstSymbolWithTargetVA: {
16521654
uint64_t ca = inputSec->getRelocTargetVA(
@@ -1745,7 +1747,7 @@ void DynamicReloc::computeRaw(Ctx &ctx, SymbolTableBaseSection *symt) {
17451747
r_offset = getOffset();
17461748
r_sym = getSymIndex(symt);
17471749
addend = computeAddend(ctx);
1748-
kind = AddendOnly; // Catch errors
1750+
kind = Computed; // Catch errors
17491751
}
17501752

17511753
void RelocationBaseSection::computeRels() {

lld/ELF/SyntheticSections.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ class StringTableSection final : public SyntheticSection {
419419
class DynamicReloc {
420420
public:
421421
enum Kind {
422+
/// The resulting dynamic relocation has already had its addend computed.
423+
/// Calling computeAddend() is an error. Only for internal use.
424+
Computed,
422425
/// The resulting dynamic relocation will not reference a symbol: #sym is
423426
/// only used to compute the addend with InputSection::getRelocTargetVA().
424427
/// Useful for various relative and TLS relocations (e.g. R_X86_64_TPOFF64).
@@ -459,6 +462,7 @@ class DynamicReloc {
459462
uint64_t getOffset() const;
460463
uint32_t getSymIndex(SymbolTableBaseSection *symTab) const;
461464
bool needsDynSymIndex() const {
465+
assert(kind != Computed && "cannot check kind after computeRaw");
462466
return kind == AgainstSymbol || kind == AgainstSymbolWithTargetVA;
463467
}
464468

0 commit comments

Comments
 (0)