Skip to content

Commit e6caa93

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

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
assert(sym == nullptr);
16521654
return addend;
@@ -1748,7 +1750,7 @@ void DynamicReloc::computeRaw(Ctx &ctx, SymbolTableBaseSection *symt) {
17481750
r_offset = getOffset();
17491751
r_sym = getSymIndex(symt);
17501752
addend = computeAddend(ctx);
1751-
kind = AddendOnly; // Catch errors
1753+
kind = Computed; // Catch errors
17521754
}
17531755

17541756
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 does not reference a symbol (#sym must
423426
/// be nullptr) and uses #addend as the result of computeAddend(ctx).
424427
AddendOnly,
@@ -461,6 +464,7 @@ class DynamicReloc {
461464
uint64_t getOffset() const;
462465
uint32_t getSymIndex(SymbolTableBaseSection *symTab) const;
463466
bool needsDynSymIndex() const {
467+
assert(kind != Computed && "cannot check kind after computeRaw");
464468
return kind == AgainstSymbol || kind == AgainstSymbolWithTargetVA;
465469
}
466470

0 commit comments

Comments
 (0)