@@ -419,26 +419,22 @@ class StringTableSection final : public SyntheticSection {
419
419
class DynamicReloc {
420
420
public:
421
421
enum Kind {
422
- // / The resulting dynamic relocation does not reference a symbol (#sym must
423
- // / be nullptr) and uses #addend as the result of computeAddend(ctx) .
424
- AddendOnly ,
422
+ // / The resulting dynamic relocation has already had its addend computed.
423
+ // / Calling computeAddend() is an error. Only for internal use .
424
+ Computed ,
425
425
// / The resulting dynamic relocation will not reference a symbol: #sym is
426
426
// / only used to compute the addend with InputSection::getRelocTargetVA().
427
427
// / Useful for various relative and TLS relocations (e.g. R_X86_64_TPOFF64).
428
- AddendOnlyWithTargetVA ,
428
+ AddendOnly ,
429
429
// / The resulting dynamic relocation references symbol #sym from the dynamic
430
- // / symbol table and uses #addend as the value of computeAddend(ctx).
430
+ // / symbol table and uses InputSection::getRelocTargetVA() for the final
431
+ // / addend.
431
432
AgainstSymbol,
432
- // / The resulting dynamic relocation references symbol #sym from the dynamic
433
- // / symbol table and uses InputSection::getRelocTargetVA() + #addend for the
434
- // / final addend. It can be used for relocations that write the symbol VA as
435
- // the addend (e.g. R_MIPS_TLS_TPREL64) but still reference the symbol.
436
- AgainstSymbolWithTargetVA,
437
433
// / This is used by the MIPS multi-GOT implementation. It relocates
438
434
// / addresses of 64kb pages that lie inside the output section.
439
435
MipsMultiGotPage,
440
436
};
441
- // / This constructor records a relocation against a symbol .
437
+ // / This constructor records a normal relocation .
442
438
DynamicReloc (RelType type, const InputSectionBase *inputSec,
443
439
uint64_t offsetInSec, Kind kind, Symbol &sym, int64_t addend,
444
440
RelExpr expr)
@@ -447,8 +443,9 @@ class DynamicReloc {
447
443
// / This constructor records a relative relocation with no symbol.
448
444
DynamicReloc (RelType type, const InputSectionBase *inputSec,
449
445
uint64_t offsetInSec, int64_t addend = 0 )
450
- : sym(nullptr ), inputSec(inputSec), offsetInSec(offsetInSec), type(type),
451
- addend(addend), kind(AddendOnly), expr(R_ADDEND) {}
446
+ : sym(inputSec->getCtx ().dummySym), inputSec(inputSec),
447
+ offsetInSec(offsetInSec), type(type), addend(addend), kind(AddendOnly),
448
+ expr(R_ADDEND) {}
452
449
// / This constructor records dynamic relocation settings used by the MIPS
453
450
// / multi-GOT implementation.
454
451
DynamicReloc (RelType type, const InputSectionBase *inputSec,
@@ -461,7 +458,8 @@ class DynamicReloc {
461
458
uint64_t getOffset () const ;
462
459
uint32_t getSymIndex (SymbolTableBaseSection *symTab) const ;
463
460
bool needsDynSymIndex () const {
464
- return kind == AgainstSymbol || kind == AgainstSymbolWithTargetVA;
461
+ assert (kind != Computed && " cannot check kind after computeRaw" );
462
+ return kind == AgainstSymbol;
465
463
}
466
464
467
465
// / Computes the addend of the dynamic relocation. Note that this is not the
@@ -528,8 +526,8 @@ class RelocationBaseSection : public SyntheticSection {
528
526
uint64_t offsetInSec, Symbol &sym, int64_t addend,
529
527
RelType addendRelType, RelExpr expr) {
530
528
assert (expr != R_ADDEND && " expected non-addend relocation expression" );
531
- addReloc<shard>(DynamicReloc::AddendOnlyWithTargetVA , dynType, isec,
532
- offsetInSec, sym, addend, expr, addendRelType);
529
+ addReloc<shard>(DynamicReloc::AddendOnly , dynType, isec, offsetInSec, sym ,
530
+ addend, expr, addendRelType);
533
531
}
534
532
// / Add a dynamic relocation using the target address of \p sym as the addend
535
533
// / if \p sym is non-preemptible. Otherwise add a relocation against \p sym.
0 commit comments