@@ -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 :
@@ -371,12 +371,12 @@ static void maybeReportRelocationToDiscarded(const SectionChunk *fromChunk,
371
371
ObjFile *file = fromChunk->file ;
372
372
std::string name;
373
373
if (sym) {
374
- name = toString (file->ctx , *sym);
374
+ name = toString (file->symtab . ctx , *sym);
375
375
} else {
376
376
COFFSymbolRef coffSym =
377
377
check (file->getCOFFObj ()->getSymbol (rel.SymbolTableIndex ));
378
378
name = maybeDemangleSymbol (
379
- file->ctx , check (file->getCOFFObj ()->getSymbolName (coffSym)));
379
+ file->symtab . ctx , check (file->getCOFFObj ()->getSymbolName (coffSym)));
380
380
}
381
381
382
382
std::vector<std::string> symbolLocations =
@@ -428,23 +428,24 @@ void SectionChunk::applyRelocation(uint8_t *off,
428
428
// section is needed to compute SECREL and SECTION relocations used in debug
429
429
// info.
430
430
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 ;
432
433
433
434
// Skip the relocation if it refers to a discarded section, and diagnose it
434
435
// as an error if appropriate. If a symbol was discarded early, it may be
435
436
// null. If it was discarded late, the output section will be null, unless
436
437
// it was an absolute or synthetic symbol.
437
438
if (!sym ||
438
439
(!os && !isa<DefinedAbsolute>(sym) && !isa<DefinedSynthetic>(sym))) {
439
- maybeReportRelocationToDiscarded (this , sym, rel, file-> ctx .config .mingw );
440
+ maybeReportRelocationToDiscarded (this , sym, rel, ctx.config .mingw );
440
441
return ;
441
442
}
442
443
443
444
uint64_t s = sym->getRVA ();
444
445
445
446
// Compute the RVA of the relocation for relative relocations.
446
447
uint64_t p = rva + rel.VirtualAddress ;
447
- uint64_t imageBase = file-> ctx .config .imageBase ;
448
+ uint64_t imageBase = ctx.config .imageBase ;
448
449
switch (getArch ()) {
449
450
case Triple::x86_64:
450
451
applyRelX64 (off, rel.Type , os, s, p, imageBase);
@@ -670,7 +671,7 @@ void SectionChunk::getRuntimePseudoRelocs(
670
671
toString (file));
671
672
continue ;
672
673
}
673
- int addressSizeInBits = file->ctx .config .is64 () ? 64 : 32 ;
674
+ int addressSizeInBits = file->symtab . ctx .config .is64 () ? 64 : 32 ;
674
675
if (sizeInBits < addressSizeInBits) {
675
676
warn (" runtime pseudo relocation in " + toString (file) + " against " +
676
677
" symbol " + target->getName () + " is too narrow (only " +
@@ -1099,7 +1100,7 @@ void CHPERedirectionChunk::writeTo(uint8_t *buf) const {
1099
1100
}
1100
1101
1101
1102
ImportThunkChunkARM64EC::ImportThunkChunkARM64EC (ImportFile *file)
1102
- : ImportThunkChunk(file->ctx, file->impSym), file(file) {}
1103
+ : ImportThunkChunk(file->symtab. ctx, file->impSym), file(file) {}
1103
1104
1104
1105
size_t ImportThunkChunkARM64EC::getSize () const {
1105
1106
if (!extended)
@@ -1123,7 +1124,7 @@ void ImportThunkChunkARM64EC::writeTo(uint8_t *buf) const {
1123
1124
applyArm64Addr (buf + 8 , exitThunkRVA, rva + 8 , 12 );
1124
1125
applyArm64Imm (buf + 12 , exitThunkRVA & 0xfff , 0 );
1125
1126
1126
- Defined *helper = cast<Defined>(file->ctx .config .arm64ECIcallHelper );
1127
+ Defined *helper = cast<Defined>(file->symtab . ctx .config .arm64ECIcallHelper );
1127
1128
if (extended) {
1128
1129
// Replace last instruction with an inline range extension thunk.
1129
1130
memcpy (buf + 16 , arm64Thunk, sizeof (arm64Thunk));
@@ -1137,7 +1138,7 @@ void ImportThunkChunkARM64EC::writeTo(uint8_t *buf) const {
1137
1138
bool ImportThunkChunkARM64EC::verifyRanges () {
1138
1139
if (extended)
1139
1140
return true ;
1140
- auto helper = cast<Defined>(file->ctx .config .arm64ECIcallHelper );
1141
+ auto helper = cast<Defined>(file->symtab . ctx .config .arm64ECIcallHelper );
1141
1142
return isInt<28 >(helper->getRVA () - rva - 16 );
1142
1143
}
1143
1144
0 commit comments