@@ -56,7 +56,7 @@ SectionChunk::SectionChunk(ObjFile *f, const coff_section *h, Kind k)
5656 // files will be built with -ffunction-sections or /Gy, so most things worth
5757 // stripping will be in a comdat.
5858 if (file)
59- live = !file->ctx .config .doGC || !isCOMDAT ();
59+ live = !file->symtab . ctx .config .doGC || !isCOMDAT ();
6060 else
6161 live = true ;
6262}
@@ -129,7 +129,7 @@ void SectionChunk::applyRelX64(uint8_t *off, uint16_t type, OutputSection *os,
129129 case IMAGE_REL_AMD64_REL32_4: add32 (off, s - p - 8 ); break ;
130130 case IMAGE_REL_AMD64_REL32_5: add32 (off, s - p - 9 ); break ;
131131 case IMAGE_REL_AMD64_SECTION:
132- applySecIdx (off, os, file->ctx .outputSections .size ());
132+ applySecIdx (off, os, file->symtab . ctx .outputSections .size ());
133133 break ;
134134 case IMAGE_REL_AMD64_SECREL: applySecRel (this , off, os, s); break ;
135135 default :
@@ -149,7 +149,7 @@ void SectionChunk::applyRelX86(uint8_t *off, uint16_t type, OutputSection *os,
149149 case IMAGE_REL_I386_DIR32NB: add32 (off, s); break ;
150150 case IMAGE_REL_I386_REL32: add32 (off, s - p - 4 ); break ;
151151 case IMAGE_REL_I386_SECTION:
152- applySecIdx (off, os, file->ctx .outputSections .size ());
152+ applySecIdx (off, os, file->symtab . ctx .outputSections .size ());
153153 break ;
154154 case IMAGE_REL_I386_SECREL: applySecRel (this , off, os, s); break ;
155155 default :
@@ -225,7 +225,7 @@ void SectionChunk::applyRelARM(uint8_t *off, uint16_t type, OutputSection *os,
225225 case IMAGE_REL_ARM_BRANCH24T: applyBranch24T (off, sx - p - 4 ); break ;
226226 case IMAGE_REL_ARM_BLX23T: applyBranch24T (off, sx - p - 4 ); break ;
227227 case IMAGE_REL_ARM_SECTION:
228- applySecIdx (off, os, file->ctx .outputSections .size ());
228+ applySecIdx (off, os, file->symtab . ctx .outputSections .size ());
229229 break ;
230230 case IMAGE_REL_ARM_SECREL: applySecRel (this , off, os, s); break ;
231231 case IMAGE_REL_ARM_REL32: add32 (off, sx - p - 4 ); break ;
@@ -346,7 +346,7 @@ void SectionChunk::applyRelARM64(uint8_t *off, uint16_t type, OutputSection *os,
346346 case IMAGE_REL_ARM64_SECREL_HIGH12A: applySecRelHigh12A (this , off, os, s); break ;
347347 case IMAGE_REL_ARM64_SECREL_LOW12L: applySecRelLdr (this , off, os, s); break ;
348348 case IMAGE_REL_ARM64_SECTION:
349- applySecIdx (off, os, file->ctx .outputSections .size ());
349+ applySecIdx (off, os, file->symtab . ctx .outputSections .size ());
350350 break ;
351351 case IMAGE_REL_ARM64_REL32: add32 (off, s - p - 4 ); break ;
352352 default :
@@ -371,12 +371,12 @@ static void maybeReportRelocationToDiscarded(const SectionChunk *fromChunk,
371371 ObjFile *file = fromChunk->file ;
372372 std::string name;
373373 if (sym) {
374- name = toString (file->ctx , *sym);
374+ name = toString (file->symtab . ctx , *sym);
375375 } else {
376376 COFFSymbolRef coffSym =
377377 check (file->getCOFFObj ()->getSymbol (rel.SymbolTableIndex ));
378378 name = maybeDemangleSymbol (
379- file->ctx , check (file->getCOFFObj ()->getSymbolName (coffSym)));
379+ file->symtab . ctx , check (file->getCOFFObj ()->getSymbolName (coffSym)));
380380 }
381381
382382 std::vector<std::string> symbolLocations =
@@ -428,23 +428,24 @@ void SectionChunk::applyRelocation(uint8_t *off,
428428 // section is needed to compute SECREL and SECTION relocations used in debug
429429 // info.
430430 Chunk *c = sym ? sym->getChunk () : nullptr ;
431- OutputSection *os = c ? file->ctx .getOutputSection (c) : nullptr ;
431+ COFFLinkerContext &ctx = file->symtab .ctx ;
432+ OutputSection *os = c ? ctx.getOutputSection (c) : nullptr ;
432433
433434 // Skip the relocation if it refers to a discarded section, and diagnose it
434435 // as an error if appropriate. If a symbol was discarded early, it may be
435436 // null. If it was discarded late, the output section will be null, unless
436437 // it was an absolute or synthetic symbol.
437438 if (!sym ||
438439 (!os && !isa<DefinedAbsolute>(sym) && !isa<DefinedSynthetic>(sym))) {
439- maybeReportRelocationToDiscarded (this , sym, rel, file-> ctx .config .mingw );
440+ maybeReportRelocationToDiscarded (this , sym, rel, ctx.config .mingw );
440441 return ;
441442 }
442443
443444 uint64_t s = sym->getRVA ();
444445
445446 // Compute the RVA of the relocation for relative relocations.
446447 uint64_t p = rva + rel.VirtualAddress ;
447- uint64_t imageBase = file-> ctx .config .imageBase ;
448+ uint64_t imageBase = ctx.config .imageBase ;
448449 switch (getArch ()) {
449450 case Triple::x86_64:
450451 applyRelX64 (off, rel.Type , os, s, p, imageBase);
@@ -670,7 +671,7 @@ void SectionChunk::getRuntimePseudoRelocs(
670671 toString (file));
671672 continue ;
672673 }
673- int addressSizeInBits = file->ctx .config .is64 () ? 64 : 32 ;
674+ int addressSizeInBits = file->symtab . ctx .config .is64 () ? 64 : 32 ;
674675 if (sizeInBits < addressSizeInBits) {
675676 warn (" runtime pseudo relocation in " + toString (file) + " against " +
676677 " symbol " + target->getName () + " is too narrow (only " +
@@ -1099,7 +1100,7 @@ void CHPERedirectionChunk::writeTo(uint8_t *buf) const {
10991100}
11001101
11011102ImportThunkChunkARM64EC::ImportThunkChunkARM64EC (ImportFile *file)
1102- : ImportThunkChunk(file->ctx, file->impSym), file(file) {}
1103+ : ImportThunkChunk(file->symtab. ctx, file->impSym), file(file) {}
11031104
11041105size_t ImportThunkChunkARM64EC::getSize () const {
11051106 if (!extended)
@@ -1123,7 +1124,7 @@ void ImportThunkChunkARM64EC::writeTo(uint8_t *buf) const {
11231124 applyArm64Addr (buf + 8 , exitThunkRVA, rva + 8 , 12 );
11241125 applyArm64Imm (buf + 12 , exitThunkRVA & 0xfff , 0 );
11251126
1126- Defined *helper = cast<Defined>(file->ctx .config .arm64ECIcallHelper );
1127+ Defined *helper = cast<Defined>(file->symtab . ctx .config .arm64ECIcallHelper );
11271128 if (extended) {
11281129 // Replace last instruction with an inline range extension thunk.
11291130 memcpy (buf + 16 , arm64Thunk, sizeof (arm64Thunk));
@@ -1137,7 +1138,7 @@ void ImportThunkChunkARM64EC::writeTo(uint8_t *buf) const {
11371138bool ImportThunkChunkARM64EC::verifyRanges () {
11381139 if (extended)
11391140 return true ;
1140- auto helper = cast<Defined>(file->ctx .config .arm64ECIcallHelper );
1141+ auto helper = cast<Defined>(file->symtab . ctx .config .arm64ECIcallHelper );
11411142 return isInt<28 >(helper->getRVA () - rva - 16 );
11421143}
11431144
0 commit comments