|
25 | 25 | #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
|
26 | 26 | #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
|
27 | 27 | #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
|
| 28 | +#include "llvm/IR/Mangler.h" |
28 | 29 | #include "llvm/LTO/LTO.h"
|
29 | 30 | #include "llvm/Object/Binary.h"
|
30 | 31 | #include "llvm/Object/COFF.h"
|
@@ -1019,9 +1020,16 @@ void ImportFile::parse() {
|
1019 | 1020 |
|
1020 | 1021 | // Read names and create an __imp_ symbol.
|
1021 | 1022 | StringRef buf = mb.getBuffer().substr(sizeof(*hdr));
|
1022 |
| - StringRef name = saver().save(buf.split('\0').first); |
| 1023 | + StringRef nameBuf = buf.split('\0').first, name; |
| 1024 | + if (isArm64EC(hdr->Machine)) { |
| 1025 | + if (std::optional<std::string> demangledName = |
| 1026 | + getArm64ECDemangledFunctionName(nameBuf)) |
| 1027 | + name = saver().save(*demangledName); |
| 1028 | + } |
| 1029 | + if (name.empty()) |
| 1030 | + name = saver().save(nameBuf); |
1023 | 1031 | StringRef impName = saver().save("__imp_" + name);
|
1024 |
| - buf = buf.substr(name.size() + 1); |
| 1032 | + buf = buf.substr(nameBuf.size() + 1); |
1025 | 1033 | dllName = buf.split('\0').first;
|
1026 | 1034 | StringRef extName;
|
1027 | 1035 | switch (hdr->getNameType()) {
|
@@ -1058,8 +1066,14 @@ void ImportFile::parse() {
|
1058 | 1066 | // If type is function, we need to create a thunk which jump to an
|
1059 | 1067 | // address pointed by the __imp_ symbol. (This allows you to call
|
1060 | 1068 | // DLL functions just like regular non-DLL functions.)
|
1061 |
| - if (hdr->getType() == llvm::COFF::IMPORT_CODE) |
1062 |
| - thunkSym = ctx.symtab.addImportThunk(name, impSym, hdr->Machine); |
| 1069 | + if (hdr->getType() == llvm::COFF::IMPORT_CODE) { |
| 1070 | + if (ctx.config.machine != ARM64EC) { |
| 1071 | + thunkSym = ctx.symtab.addImportThunk(name, impSym, hdr->Machine); |
| 1072 | + } else { |
| 1073 | + thunkSym = ctx.symtab.addImportThunk(name, impSym, AMD64); |
| 1074 | + // FIXME: Add aux IAT symbols. |
| 1075 | + } |
| 1076 | + } |
1063 | 1077 | }
|
1064 | 1078 |
|
1065 | 1079 | BitcodeFile::BitcodeFile(COFFLinkerContext &ctx, MemoryBufferRef mb,
|
|
0 commit comments