@@ -911,21 +911,18 @@ uint64_t DelayLoadContents::getDirSize() {
911911 return dirs.size () * sizeof (delay_import_directory_table_entry);
912912}
913913
914- void DelayLoadContents::create (Defined *h) {
915- helper = h;
914+ void DelayLoadContents::create () {
916915 std::vector<std::vector<DefinedImportData *>> v = binImports (ctx, imports);
917916
918- Chunk *unwind = newTailMergeUnwindInfoChunk ();
919-
920917 // Create .didat contents for each DLL.
921918 for (std::vector<DefinedImportData *> &syms : v) {
922919 // Create the delay import table header.
923920 dllNames.push_back (make<StringChunk>(syms[0 ]->getDLLName ()));
924921 auto *dir = make<DelayDirectoryChunk>(dllNames.back ());
925922
926923 size_t base = addresses.size ();
927- Chunk *tm = newTailMergeChunk (dir);
928- Chunk *pdataChunk = unwind ? newTailMergePDataChunk (tm, unwind) : nullptr ;
924+ Chunk *tm = newTailMergeChunk (ctx. symtab , dir);
925+ Chunk *pdataChunk = newTailMergePDataChunk (ctx. symtab , tm) ;
929926 for (DefinedImportData *s : syms) {
930927 Chunk *t = newThunkChunk (s, tm);
931928 auto *a = make<DelayAddressChunk>(ctx, t);
@@ -982,15 +979,18 @@ void DelayLoadContents::create(Defined *h) {
982979 dirs.push_back (dir);
983980 }
984981
985- if (unwind)
986- unwindinfo.push_back (unwind);
982+ ctx.forEachSymtab ([&](SymbolTable &symtab) {
983+ if (symtab.tailMergeUnwindInfoChunk )
984+ unwindinfo.push_back (symtab.tailMergeUnwindInfoChunk );
985+ });
987986 // Add null terminator.
988987 dirs.push_back (
989988 make<NullChunk>(sizeof (delay_import_directory_table_entry), 4 ));
990989}
991990
992- Chunk *DelayLoadContents::newTailMergeChunk (Chunk *dir) {
993- switch (ctx.config .machine ) {
991+ Chunk *DelayLoadContents::newTailMergeChunk (SymbolTable &symtab, Chunk *dir) {
992+ auto helper = cast<Defined>(symtab.delayLoadHelper );
993+ switch (symtab.machine ) {
994994 case AMD64:
995995 case ARM64EC:
996996 return make<TailMergeChunkX64>(dir, helper);
@@ -1005,21 +1005,14 @@ Chunk *DelayLoadContents::newTailMergeChunk(Chunk *dir) {
10051005 }
10061006}
10071007
1008- Chunk *DelayLoadContents::newTailMergeUnwindInfoChunk () {
1009- switch (ctx.config .machine ) {
1010- case AMD64:
1011- case ARM64EC:
1012- return make<TailMergeUnwindInfoX64>();
1013- // FIXME: Add support for other architectures.
1014- default :
1015- return nullptr ; // Just don't generate unwind info.
1016- }
1017- }
1018- Chunk *DelayLoadContents::newTailMergePDataChunk (Chunk *tm, Chunk *unwind) {
1019- switch (ctx.config .machine ) {
1008+ Chunk *DelayLoadContents::newTailMergePDataChunk (SymbolTable &symtab,
1009+ Chunk *tm) {
1010+ switch (symtab.machine ) {
10201011 case AMD64:
10211012 case ARM64EC:
1022- return make<TailMergePDataChunkX64>(tm, unwind);
1013+ if (!symtab.tailMergeUnwindInfoChunk )
1014+ symtab.tailMergeUnwindInfoChunk = make<TailMergeUnwindInfoX64>();
1015+ return make<TailMergePDataChunkX64>(tm, symtab.tailMergeUnwindInfoChunk );
10231016 // FIXME: Add support for other architectures.
10241017 default :
10251018 return nullptr ; // Just don't generate unwind info.
@@ -1028,7 +1021,7 @@ Chunk *DelayLoadContents::newTailMergePDataChunk(Chunk *tm, Chunk *unwind) {
10281021
10291022Chunk *DelayLoadContents::newThunkChunk (DefinedImportData *s,
10301023 Chunk *tailMerge) {
1031- switch (ctx. config . machine ) {
1024+ switch (s-> file -> getMachineType () ) {
10321025 case AMD64:
10331026 case ARM64EC:
10341027 return make<ThunkChunkX64>(s, tailMerge);
0 commit comments