@@ -769,10 +769,6 @@ void GotSection::writeTo(uint8_t *buf) {
769769 }
770770}
771771
772- static uint64_t getMipsPageAddr (uint64_t addr) {
773- return (addr + 0x8000 ) & ~0xffff ;
774- }
775-
776772static uint64_t getMipsPageCount (uint64_t size) {
777773 return (size + 0xfffe ) / 0xffff + 1 ;
778774}
@@ -786,7 +782,7 @@ void MipsGotSection::addEntry(InputFile &file, Symbol &sym, int64_t addend,
786782 FileGot &g = getGot (file);
787783 if (expr == RE_MIPS_GOT_LOCAL_PAGE) {
788784 if (const OutputSection *os = sym.getOutputSection ())
789- g.pagesMap .insert ({os, {}});
785+ g.pagesMap .insert ({os, {&sym }});
790786 else
791787 g.local16 .insert ({{nullptr , getMipsPageAddr (sym.getVA (ctx, addend))}, 0 });
792788 } else if (sym.isTls ())
@@ -1065,9 +1061,9 @@ void MipsGotSection::build() {
10651061 // for the TP-relative offset as we don't know how much other data will
10661062 // be allocated before us in the static TLS block.
10671063 if (s->isPreemptible || ctx.arg .shared )
1068- ctx.mainPart ->relaDyn ->addReloc (
1069- {ctx. target -> tlsGotRel , this , offset ,
1070- DynamicReloc::AgainstSymbolWithTargetVA, *s, 0 , R_ABS});
1064+ ctx.mainPart ->relaDyn ->addReloc ({ctx. target -> tlsGotRel , this , offset,
1065+ DynamicReloc::AgainstSymbol, *s, 0 ,
1066+ R_ABS});
10711067 }
10721068 for (std::pair<Symbol *, size_t > &p : got.dynTlsSymbols ) {
10731069 Symbol *s = p.first ;
@@ -1115,15 +1111,16 @@ void MipsGotSection::build() {
11151111 size_t pageCount = l.second .count ;
11161112 for (size_t pi = 0 ; pi < pageCount; ++pi) {
11171113 uint64_t offset = (l.second .firstIndex + pi) * ctx.arg .wordsize ;
1118- ctx.mainPart ->relaDyn ->addReloc ({ctx.target ->relativeRel , this , offset,
1119- l.first , int64_t (pi * 0x10000 )});
1114+ ctx.mainPart ->relaDyn ->addReloc (
1115+ {ctx.target ->relativeRel , this , offset, DynamicReloc::AddendOnly,
1116+ *l.second .repSym , int64_t (pi * 0x10000 ), RE_MIPS_OSEC_LOCAL_PAGE});
11201117 }
11211118 }
11221119 for (const std::pair<GotEntry, size_t > &p : got.local16 ) {
11231120 uint64_t offset = p.second * ctx.arg .wordsize ;
11241121 ctx.mainPart ->relaDyn ->addReloc ({ctx.target ->relativeRel , this , offset,
1125- DynamicReloc::AddendOnlyWithTargetVA ,
1126- *p. first . first , p.first .second , R_ABS});
1122+ DynamicReloc::AddendOnly, *p. first . first ,
1123+ p.first .second , R_ABS});
11271124 }
11281125 }
11291126}
@@ -1647,21 +1644,14 @@ uint64_t DynamicReloc::getOffset() const {
16471644
16481645int64_t DynamicReloc::computeAddend (Ctx &ctx) const {
16491646 switch (kind) {
1647+ case Computed:
1648+ llvm_unreachable (" addend already computed" );
16501649 case AddendOnly:
1651- assert (sym == nullptr );
1652- return addend;
1653- case AgainstSymbol:
1654- assert (sym != nullptr );
1655- return addend;
1656- case AddendOnlyWithTargetVA:
1657- case AgainstSymbolWithTargetVA: {
1650+ case AgainstSymbol: {
16581651 uint64_t ca = inputSec->getRelocTargetVA (
16591652 ctx, Relocation{expr, type, 0 , addend, sym}, getOffset ());
16601653 return ctx.arg .is64 ? ca : SignExtend64<32 >(ca);
16611654 }
1662- case MipsMultiGotPage:
1663- assert (sym == nullptr );
1664- return getMipsPageAddr (outputSec->addr ) + addend;
16651655 }
16661656 llvm_unreachable (" Unknown DynamicReloc::Kind enum" );
16671657}
@@ -1701,10 +1691,10 @@ void RelocationBaseSection::addAddendOnlyRelocIfNonPreemptible(
17011691 // No need to write an addend to the section for preemptible symbols.
17021692 if (sym.isPreemptible )
17031693 addReloc ({dynType, &isec, offsetInSec, DynamicReloc::AgainstSymbol, sym, 0 ,
1704- R_ABS });
1694+ R_ADDEND });
17051695 else
1706- addReloc (DynamicReloc::AddendOnlyWithTargetVA , dynType, isec, offsetInSec,
1707- sym, 0 , R_ABS, addendRelType);
1696+ addReloc (DynamicReloc::AddendOnly , dynType, isec, offsetInSec, sym, 0 ,
1697+ R_ABS, addendRelType);
17081698}
17091699
17101700void RelocationBaseSection::mergeRels () {
@@ -1748,7 +1738,7 @@ void DynamicReloc::computeRaw(Ctx &ctx, SymbolTableBaseSection *symt) {
17481738 r_offset = getOffset ();
17491739 r_sym = getSymIndex (symt);
17501740 addend = computeAddend (ctx);
1751- kind = AddendOnly ; // Catch errors
1741+ kind = Computed ; // Catch errors
17521742}
17531743
17541744void RelocationBaseSection::computeRels () {
0 commit comments