Skip to content

Commit 25eac05

Browse files
committed
Rebased
Created using spr 1.3.5
2 parents df0dc61 + 8511366 commit 25eac05

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
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 AgainstSymbol: {
16521654
uint64_t ca = inputSec->getRelocTargetVA(
@@ -1742,7 +1744,7 @@ void DynamicReloc::computeRaw(Ctx &ctx, SymbolTableBaseSection *symt) {
17421744
r_offset = getOffset();
17431745
r_sym = getSymIndex(symt);
17441746
addend = computeAddend(ctx);
1745-
kind = AddendOnly; // Catch errors
1747+
kind = Computed; // Catch errors
17461748
}
17471749

17481750
void RelocationBaseSection::computeRels() {

lld/ELF/SyntheticSections.h

Lines changed: 7 additions & 1 deletion
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).
@@ -454,7 +457,10 @@ class DynamicReloc {
454457

455458
uint64_t getOffset() const;
456459
uint32_t getSymIndex(SymbolTableBaseSection *symTab) const;
457-
bool needsDynSymIndex() const { return kind == AgainstSymbol; }
460+
bool needsDynSymIndex() const {
461+
assert(kind != Computed && "cannot check kind after computeRaw");
462+
return kind == AgainstSymbol;
463+
}
458464

459465
/// Computes the addend of the dynamic relocation. Note that this is not the
460466
/// same as the #addend member variable as it may also include the symbol

0 commit comments

Comments
 (0)