@@ -1359,14 +1359,14 @@ void Writer::createExportTable() {
13591359
13601360 for (auto chunk : edataSec->chunks ) {
13611361 if (chunk->getMachine () != ARM64) {
1362- ctx.hybridSymtab -> edataStart = chunk;
1363- ctx.hybridSymtab -> edataEnd = edataSec->chunks .back ();
1362+ ctx.symtab . edataStart = chunk;
1363+ ctx.symtab . edataEnd = edataSec->chunks .back ();
13641364 break ;
13651365 }
13661366
1367- if (!ctx.symtab . edataStart )
1368- ctx.symtab . edataStart = chunk;
1369- ctx.symtab . edataEnd = chunk;
1367+ if (!ctx.hybridSymtab -> edataStart )
1368+ ctx.hybridSymtab -> edataStart = chunk;
1369+ ctx.hybridSymtab -> edataEnd = chunk;
13701370 }
13711371 }
13721372 }
@@ -1760,7 +1760,8 @@ template <typename PEHeaderTy> void Writer::writeHeader() {
17601760 assert (coffHeaderOffset == buf - buffer->getBufferStart ());
17611761 auto *coff = reinterpret_cast <coff_file_header *>(buf);
17621762 buf += sizeof (*coff);
1763- coff->Machine = ctx.symtab .isEC () ? AMD64 : ctx.symtab .machine ;
1763+ SymbolTable &symtab = ctx.hybridSymtab ? *ctx.hybridSymtab : ctx.symtab ;
1764+ coff->Machine = symtab.isEC () ? AMD64 : symtab.machine ;
17641765 coff->NumberOfSections = ctx.outputSections .size ();
17651766 coff->Characteristics = IMAGE_FILE_EXECUTABLE_IMAGE;
17661767 if (config->largeAddressAware )
@@ -1807,7 +1808,7 @@ template <typename PEHeaderTy> void Writer::writeHeader() {
18071808 pe->SizeOfImage = sizeOfImage;
18081809 pe->SizeOfHeaders = sizeOfHeaders;
18091810 if (!config->noEntry ) {
1810- Defined *entry = cast<Defined>(ctx. symtab .entry );
1811+ Defined *entry = cast<Defined>(symtab.entry );
18111812 pe->AddressOfEntryPoint = entry->getRVA ();
18121813 // Pointer to thumb code must have the LSB set, so adjust it.
18131814 if (config->machine == ARMNT)
@@ -1851,11 +1852,11 @@ template <typename PEHeaderTy> void Writer::writeHeader() {
18511852 dataDirOffset64 == buf - buffer->getBufferStart ());
18521853 auto *dir = reinterpret_cast <data_directory *>(buf);
18531854 buf += sizeof (*dir) * numberOfDataDirectory;
1854- if (ctx. symtab .edataStart ) {
1855- dir[EXPORT_TABLE].RelativeVirtualAddress = ctx. symtab .edataStart ->getRVA ();
1856- dir[EXPORT_TABLE].Size = ctx. symtab .edataEnd ->getRVA () +
1857- ctx. symtab .edataEnd ->getSize () -
1858- ctx. symtab .edataStart ->getRVA ();
1855+ if (symtab.edataStart ) {
1856+ dir[EXPORT_TABLE].RelativeVirtualAddress = symtab.edataStart ->getRVA ();
1857+ dir[EXPORT_TABLE].Size = symtab.edataEnd ->getRVA () +
1858+ symtab.edataEnd ->getSize () -
1859+ symtab.edataStart ->getRVA ();
18591860 }
18601861 if (importTableStart) {
18611862 dir[IMPORT_TABLE].RelativeVirtualAddress = importTableStart->getRVA ();
@@ -1886,7 +1887,7 @@ template <typename PEHeaderTy> void Writer::writeHeader() {
18861887 dir[BASE_RELOCATION_TABLE].RelativeVirtualAddress = relocSec->getRVA ();
18871888 dir[BASE_RELOCATION_TABLE].Size = relocSize;
18881889 }
1889- if (Symbol *sym = ctx. symtab .findUnderscore (" _tls_used" )) {
1890+ if (Symbol *sym = symtab.findUnderscore (" _tls_used" )) {
18901891 if (Defined *b = dyn_cast<Defined>(sym)) {
18911892 dir[TLS_TABLE].RelativeVirtualAddress = b->getRVA ();
18921893 dir[TLS_TABLE].Size = config->is64 ()
@@ -1898,10 +1899,10 @@ template <typename PEHeaderTy> void Writer::writeHeader() {
18981899 dir[DEBUG_DIRECTORY].RelativeVirtualAddress = debugDirectory->getRVA ();
18991900 dir[DEBUG_DIRECTORY].Size = debugDirectory->getSize ();
19001901 }
1901- if (ctx. symtab .loadConfigSym ) {
1902+ if (symtab.loadConfigSym ) {
19021903 dir[LOAD_CONFIG_TABLE].RelativeVirtualAddress =
1903- ctx. symtab .loadConfigSym ->getRVA ();
1904- dir[LOAD_CONFIG_TABLE].Size = ctx. symtab .loadConfigSize ;
1904+ symtab.loadConfigSym ->getRVA ();
1905+ dir[LOAD_CONFIG_TABLE].Size = symtab.loadConfigSize ;
19051906 }
19061907 if (!delayIdata.empty ()) {
19071908 dir[DELAY_IMPORT_DESCRIPTOR].RelativeVirtualAddress =
@@ -2442,7 +2443,7 @@ void Writer::setECSymbols() {
24422443 // For the hybrid image, set the alternate entry point to the EC entry
24432444 // point. In the hybrid view, it is swapped to the native entry point
24442445 // using ARM64X relocations.
2445- if (auto altEntrySym = cast_or_null<Defined>(ctx.hybridSymtab -> entry )) {
2446+ if (auto altEntrySym = cast_or_null<Defined>(ctx.symtab . entry )) {
24462447 // If the entry is an EC export thunk, use its target instead.
24472448 if (auto thunkChunk =
24482449 dyn_cast<ECExportThunkChunk>(altEntrySym->getChunk ()))
@@ -2711,7 +2712,7 @@ void Writer::createDynamicRelocs() {
27112712 if (ctx.symtab .entry != ctx.hybridSymtab ->entry ||
27122713 pdata.first != hybridPdata.first ) {
27132714 chpeSym = cast_or_null<DefinedRegular>(
2714- ctx.hybridSymtab -> findUnderscore (" __chpe_metadata" ));
2715+ ctx.symtab . findUnderscore (" __chpe_metadata" ));
27152716 if (!chpeSym)
27162717 Warn (ctx) << " '__chpe_metadata' is missing for ARM64X target" ;
27172718 }
@@ -2720,22 +2721,22 @@ void Writer::createDynamicRelocs() {
27202721 ctx.dynamicRelocs ->add (IMAGE_DVRT_ARM64X_FIXUP_TYPE_VALUE, sizeof (uint32_t ),
27212722 peHeaderOffset +
27222723 offsetof (pe32plus_header, AddressOfEntryPoint),
2723- cast_or_null<Defined>(ctx.hybridSymtab -> entry ));
2724+ cast_or_null<Defined>(ctx.symtab . entry ));
27242725
27252726 // Swap the alternate entry point in the CHPE metadata.
27262727 if (chpeSym)
27272728 ctx.dynamicRelocs ->add (
27282729 IMAGE_DVRT_ARM64X_FIXUP_TYPE_VALUE, sizeof (uint32_t ),
27292730 Arm64XRelocVal (chpeSym, offsetof (chpe_metadata, AlternateEntryPoint)),
2730- cast_or_null<Defined>(ctx.symtab . entry ));
2731+ cast_or_null<Defined>(ctx.hybridSymtab -> entry ));
27312732 }
27322733
27332734 if (ctx.symtab .edataStart != ctx.hybridSymtab ->edataStart ) {
27342735 ctx.dynamicRelocs ->add (IMAGE_DVRT_ARM64X_FIXUP_TYPE_VALUE, sizeof (uint32_t ),
27352736 dataDirOffset64 +
27362737 EXPORT_TABLE * sizeof (data_directory) +
27372738 offsetof (data_directory, RelativeVirtualAddress),
2738- ctx.hybridSymtab -> edataStart );
2739+ ctx.symtab . edataStart );
27392740 // The Size value is assigned after addresses are finalized.
27402741 ctx.dynamicRelocs ->add (IMAGE_DVRT_ARM64X_FIXUP_TYPE_VALUE, sizeof (uint32_t ),
27412742 dataDirOffset64 +
@@ -2773,12 +2774,12 @@ void Writer::createDynamicRelocs() {
27732774 dataDirOffset64 +
27742775 LOAD_CONFIG_TABLE * sizeof (data_directory) +
27752776 offsetof (data_directory, RelativeVirtualAddress),
2776- ctx.hybridSymtab -> loadConfigSym );
2777+ ctx.symtab . loadConfigSym );
27772778 ctx.dynamicRelocs ->add (IMAGE_DVRT_ARM64X_FIXUP_TYPE_VALUE, sizeof (uint32_t ),
27782779 dataDirOffset64 +
27792780 LOAD_CONFIG_TABLE * sizeof (data_directory) +
27802781 offsetof (data_directory, Size),
2781- ctx.hybridSymtab -> loadConfigSize );
2782+ ctx.symtab . loadConfigSize );
27822783}
27832784
27842785PartialSection *Writer::createPartialSection (StringRef name,
@@ -2889,15 +2890,14 @@ void Writer::prepareLoadConfig(SymbolTable &symtab, T *loadConfig) {
28892890 // On ARM64X, only the EC version of the load config contains
28902891 // CHPEMetadataPointer. Copy its value to the native load config.
28912892 if (ctx.hybridSymtab && !symtab.isEC () &&
2892- ctx.hybridSymtab -> loadConfigSize >=
2893+ ctx.symtab . loadConfigSize >=
28932894 offsetof (T, CHPEMetadataPointer) + sizeof (T::CHPEMetadataPointer)) {
28942895 OutputSection *sec =
2895- ctx.getOutputSection (ctx.hybridSymtab -> loadConfigSym ->getChunk ());
2896+ ctx.getOutputSection (ctx.symtab . loadConfigSym ->getChunk ());
28962897 uint8_t *secBuf = buffer->getBufferStart () + sec->getFileOff ();
28972898 auto hybridLoadConfig =
28982899 reinterpret_cast <const coff_load_configuration64 *>(
2899- secBuf +
2900- (ctx.hybridSymtab ->loadConfigSym ->getRVA () - sec->getRVA ()));
2900+ secBuf + (ctx.symtab .loadConfigSym ->getRVA () - sec->getRVA ()));
29012901 loadConfig->CHPEMetadataPointer = hybridLoadConfig->CHPEMetadataPointer ;
29022902 }
29032903 }
0 commit comments