summaryrefslogtreecommitdiff
path: root/llvm/lib/Object/COFFImportFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Object/COFFImportFile.cpp')
-rw-r--r--llvm/lib/Object/COFFImportFile.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/llvm/lib/Object/COFFImportFile.cpp b/llvm/lib/Object/COFFImportFile.cpp
index 46c8e702581e..48c3ea0ed8f4 100644
--- a/llvm/lib/Object/COFFImportFile.cpp
+++ b/llvm/lib/Object/COFFImportFile.cpp
@@ -84,6 +84,27 @@ StringRef COFFImportFile::getExportName() const {
return name;
}
+Error COFFImportFile::printSymbolName(raw_ostream &OS, DataRefImpl Symb) const {
+ switch (Symb.p) {
+ case ImpSymbol:
+ OS << "__imp_";
+ break;
+ case ECAuxSymbol:
+ OS << "__imp_aux_";
+ break;
+ }
+ const char *Name = Data.getBufferStart() + sizeof(coff_import_header);
+ if (Symb.p != ECThunkSymbol && COFF::isArm64EC(getMachine())) {
+ if (std::optional<std::string> DemangledName =
+ getArm64ECDemangledFunctionName(Name)) {
+ OS << StringRef(*DemangledName);
+ return Error::success();
+ }
+ }
+ OS << StringRef(Name);
+ return Error::success();
+}
+
static uint16_t getImgRelRelocation(MachineTypes Machine) {
switch (Machine) {
default:
@@ -626,8 +647,11 @@ Error writeImportLibrary(StringRef ImportName, StringRef Path,
MachineTypes Machine, bool MinGW,
ArrayRef<COFFShortExport> NativeExports) {
- MachineTypes NativeMachine =
- isArm64EC(Machine) ? IMAGE_FILE_MACHINE_ARM64 : Machine;
+ MachineTypes NativeMachine = Machine;
+ if (isArm64EC(Machine)) {
+ NativeMachine = IMAGE_FILE_MACHINE_ARM64;
+ Machine = IMAGE_FILE_MACHINE_ARM64EC;
+ }
std::vector<NewArchiveMember> Members;
ObjectFactory OF(llvm::sys::path::filename(ImportName), NativeMachine);
@@ -687,12 +711,12 @@ Error writeImportLibrary(StringRef ImportName, StringRef Path,
if (ImportType == IMPORT_CODE && isArm64EC(M)) {
if (std::optional<std::string> MangledName =
getArm64ECMangledFunctionName(Name)) {
- if (ExportName.empty()) {
+ if (!E.Noname && ExportName.empty()) {
NameType = IMPORT_NAME_EXPORTAS;
ExportName.swap(Name);
}
Name = std::move(*MangledName);
- } else if (ExportName.empty()) {
+ } else if (!E.Noname && ExportName.empty()) {
NameType = IMPORT_NAME_EXPORTAS;
ExportName = std::move(*getArm64ECDemangledFunctionName(Name));
}