Skip to content

[Object][COFF][NFC] Don't use inline function for COFFImportFile::printSymbolName. #87195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions llvm/include/llvm/Object/COFFImportFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,7 @@ class COFFImportFile : public SymbolicFile {

void moveSymbolNext(DataRefImpl &Symb) const override { ++Symb.p; }

Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override {
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();
}
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override;

Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override {
return SymbolRef::SF_Global;
Expand Down
21 changes: 21 additions & 0 deletions llvm/lib/Object/COFFImportFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down