@@ -56,7 +56,7 @@ SectionChunk::SectionChunk(ObjFile *f, const coff_section *h, Kind k)
56
56
// files will be built with -ffunction-sections or /Gy, so most things worth
57
57
// stripping will be in a comdat.
58
58
if (file)
59
- live = !file->ctx .config .doGC || !isCOMDAT ();
59
+ live = !file->symtab . ctx .config .doGC || !isCOMDAT ();
60
60
else
61
61
live = true ;
62
62
}
@@ -129,7 +129,7 @@ void SectionChunk::applyRelX64(uint8_t *off, uint16_t type, OutputSection *os,
129
129
case IMAGE_REL_AMD64_REL32_4: add32 (off, s - p - 8 ); break ;
130
130
case IMAGE_REL_AMD64_REL32_5: add32 (off, s - p - 9 ); break ;
131
131
case IMAGE_REL_AMD64_SECTION:
132
- applySecIdx (off, os, file->ctx .outputSections .size ());
132
+ applySecIdx (off, os, file->symtab . ctx .outputSections .size ());
133
133
break ;
134
134
case IMAGE_REL_AMD64_SECREL: applySecRel (this , off, os, s); break ;
135
135
default :
@@ -149,7 +149,7 @@ void SectionChunk::applyRelX86(uint8_t *off, uint16_t type, OutputSection *os,
149
149
case IMAGE_REL_I386_DIR32NB: add32 (off, s); break ;
150
150
case IMAGE_REL_I386_REL32: add32 (off, s - p - 4 ); break ;
151
151
case IMAGE_REL_I386_SECTION:
152
- applySecIdx (off, os, file->ctx .outputSections .size ());
152
+ applySecIdx (off, os, file->symtab . ctx .outputSections .size ());
153
153
break ;
154
154
case IMAGE_REL_I386_SECREL: applySecRel (this , off, os, s); break ;
155
155
default :
@@ -225,7 +225,7 @@ void SectionChunk::applyRelARM(uint8_t *off, uint16_t type, OutputSection *os,
225
225
case IMAGE_REL_ARM_BRANCH24T: applyBranch24T (off, sx - p - 4 ); break ;
226
226
case IMAGE_REL_ARM_BLX23T: applyBranch24T (off, sx - p - 4 ); break ;
227
227
case IMAGE_REL_ARM_SECTION:
228
- applySecIdx (off, os, file->ctx .outputSections .size ());
228
+ applySecIdx (off, os, file->symtab . ctx .outputSections .size ());
229
229
break ;
230
230
case IMAGE_REL_ARM_SECREL: applySecRel (this , off, os, s); break ;
231
231
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,
346
346
case IMAGE_REL_ARM64_SECREL_HIGH12A: applySecRelHigh12A (this , off, os, s); break ;
347
347
case IMAGE_REL_ARM64_SECREL_LOW12L: applySecRelLdr (this , off, os, s); break ;
348
348
case IMAGE_REL_ARM64_SECTION:
349
- applySecIdx (off, os, file->ctx .outputSections .size ());
349
+ applySecIdx (off, os, file->symtab . ctx .outputSections .size ());
350
350
break ;
351
351
case IMAGE_REL_ARM64_REL32: add32 (off, s - p - 4 ); break ;
352
352
default :
@@ -427,23 +427,24 @@ void SectionChunk::applyRelocation(uint8_t *off,
427
427
// section is needed to compute SECREL and SECTION relocations used in debug
428
428
// info.
429
429
Chunk *c = sym ? sym->getChunk () : nullptr ;
430
- OutputSection *os = c ? file->ctx .getOutputSection (c) : nullptr ;
430
+ COFFLinkerContext &ctx = file->symtab .ctx ;
431
+ OutputSection *os = c ? ctx.getOutputSection (c) : nullptr ;
431
432
432
433
// Skip the relocation if it refers to a discarded section, and diagnose it
433
434
// as an error if appropriate. If a symbol was discarded early, it may be
434
435
// null. If it was discarded late, the output section will be null, unless
435
436
// it was an absolute or synthetic symbol.
436
437
if (!sym ||
437
438
(!os && !isa<DefinedAbsolute>(sym) && !isa<DefinedSynthetic>(sym))) {
438
- maybeReportRelocationToDiscarded (this , sym, rel, file-> ctx .config .mingw );
439
+ maybeReportRelocationToDiscarded (this , sym, rel, ctx.config .mingw );
439
440
return ;
440
441
}
441
442
442
443
uint64_t s = sym->getRVA ();
443
444
444
445
// Compute the RVA of the relocation for relative relocations.
445
446
uint64_t p = rva + rel.VirtualAddress ;
446
- uint64_t imageBase = file-> ctx .config .imageBase ;
447
+ uint64_t imageBase = ctx.config .imageBase ;
447
448
switch (getArch ()) {
448
449
case Triple::x86_64:
449
450
applyRelX64 (off, rel.Type , os, s, p, imageBase);
@@ -669,7 +670,7 @@ void SectionChunk::getRuntimePseudoRelocs(
669
670
toString (file));
670
671
continue ;
671
672
}
672
- int addressSizeInBits = file->ctx .config .is64 () ? 64 : 32 ;
673
+ int addressSizeInBits = file->symtab . ctx .config .is64 () ? 64 : 32 ;
673
674
if (sizeInBits < addressSizeInBits) {
674
675
warn (" runtime pseudo relocation in " + toString (file) + " against " +
675
676
" symbol " + target->getName () + " is too narrow (only " +
@@ -1098,7 +1099,7 @@ void CHPERedirectionChunk::writeTo(uint8_t *buf) const {
1098
1099
}
1099
1100
1100
1101
ImportThunkChunkARM64EC::ImportThunkChunkARM64EC (ImportFile *file)
1101
- : ImportThunkChunk(file->ctx, file->impSym), file(file) {}
1102
+ : ImportThunkChunk(file->symtab. ctx, file->impSym), file(file) {}
1102
1103
1103
1104
size_t ImportThunkChunkARM64EC::getSize () const {
1104
1105
if (!extended)
@@ -1122,7 +1123,7 @@ void ImportThunkChunkARM64EC::writeTo(uint8_t *buf) const {
1122
1123
applyArm64Addr (buf + 8 , exitThunkRVA, rva + 8 , 12 );
1123
1124
applyArm64Imm (buf + 12 , exitThunkRVA & 0xfff , 0 );
1124
1125
1125
- Defined *helper = cast<Defined>(file->ctx .config .arm64ECIcallHelper );
1126
+ Defined *helper = cast<Defined>(file->symtab . ctx .config .arm64ECIcallHelper );
1126
1127
if (extended) {
1127
1128
// Replace last instruction with an inline range extension thunk.
1128
1129
memcpy (buf + 16 , arm64Thunk, sizeof (arm64Thunk));
@@ -1136,7 +1137,7 @@ void ImportThunkChunkARM64EC::writeTo(uint8_t *buf) const {
1136
1137
bool ImportThunkChunkARM64EC::verifyRanges () {
1137
1138
if (extended)
1138
1139
return true ;
1139
- auto helper = cast<Defined>(file->ctx .config .arm64ECIcallHelper );
1140
+ auto helper = cast<Defined>(file->symtab . ctx .config .arm64ECIcallHelper );
1140
1141
return isInt<28 >(helper->getRVA () - rva - 16 );
1141
1142
}
1142
1143
0 commit comments