@@ -1009,6 +1009,20 @@ MachineTypes ImportFile::getMachineType() const {
10091009 return MachineTypes (machine);
10101010}
10111011
1012+ ImportThunkChunk *ImportFile::makeImportThunk () {
1013+ switch (hdr->Machine ) {
1014+ case AMD64:
1015+ return make<ImportThunkChunkX64>(ctx, impSym);
1016+ case I386:
1017+ return make<ImportThunkChunkX86>(ctx, impSym);
1018+ case ARM64:
1019+ return make<ImportThunkChunkARM64>(ctx, impSym);
1020+ case ARMNT:
1021+ return make<ImportThunkChunkARM>(ctx, impSym);
1022+ }
1023+ llvm_unreachable (" unknown machine type" );
1024+ }
1025+
10121026void ImportFile::parse () {
10131027 const auto *hdr =
10141028 reinterpret_cast <const coff_import_header *>(mb.getBufferStart ());
@@ -1069,9 +1083,10 @@ void ImportFile::parse() {
10691083 // DLL functions just like regular non-DLL functions.)
10701084 if (hdr->getType () == llvm::COFF::IMPORT_CODE) {
10711085 if (ctx.config .machine != ARM64EC) {
1072- thunkSym = ctx.symtab .addImportThunk (name, impSym, hdr-> Machine );
1086+ thunkSym = ctx.symtab .addImportThunk (name, impSym, makeImportThunk () );
10731087 } else {
1074- thunkSym = ctx.symtab .addImportThunk (name, impSym, AMD64);
1088+ thunkSym = ctx.symtab .addImportThunk (
1089+ name, impSym, make<ImportThunkChunkX64>(ctx, impSym));
10751090 // FIXME: Add aux IAT symbols.
10761091 }
10771092 }
0 commit comments