[LLD][COFF] Support GNU style == aliases
D46245 added support for this in llvm-libtool, but while lld-link can also create .lib files from .def files it didn't support aliases. I compared the Inputs/library.def test against the output from llvm-libtool and it matches, except for the fact that lld-link reorders functions for some reason. I have also verified that this fixes a bug I was running into while trying to compile .def files to .lib files in MinGW-w64 (using lld-link instead of llvm-libtool). Differential Revision: https://reviews.llvm.org/D113365
This commit is contained in:
parent
579c4921c0
commit
d649faff9c
|
|
@ -43,6 +43,7 @@ static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386;
|
|||
struct Export {
|
||||
StringRef name; // N in /export:N or /export:E=N
|
||||
StringRef extName; // E in /export:E=N
|
||||
StringRef aliasTarget; // GNU specific: N in "alias == N"
|
||||
Symbol *sym = nullptr;
|
||||
uint16_t ordinal = 0;
|
||||
bool noname = false;
|
||||
|
|
@ -63,6 +64,7 @@ struct Export {
|
|||
|
||||
bool operator==(const Export &e) {
|
||||
return (name == e.name && extName == e.extName &&
|
||||
aliasTarget == e.aliasTarget &&
|
||||
ordinal == e.ordinal && noname == e.noname &&
|
||||
data == e.data && isPrivate == e.isPrivate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -810,6 +810,7 @@ static void createImportLibrary(bool asLib) {
|
|||
e2.Name = std::string(e1.name);
|
||||
e2.SymbolName = std::string(e1.symbolName);
|
||||
e2.ExtName = std::string(e1.extName);
|
||||
e2.AliasTarget = std::string(e1.aliasTarget);
|
||||
e2.Ordinal = e1.ordinal;
|
||||
e2.Noname = e1.noname;
|
||||
e2.Data = e1.data;
|
||||
|
|
@ -908,6 +909,7 @@ static void parseModuleDefs(StringRef path) {
|
|||
}
|
||||
e2.name = saver.save(e1.Name);
|
||||
e2.extName = saver.save(e1.ExtName);
|
||||
e2.aliasTarget = saver.save(e1.AliasTarget);
|
||||
e2.ordinal = e1.Ordinal;
|
||||
e2.noname = e1.Noname;
|
||||
e2.data = e1.Data;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
LIBRARY library
|
||||
EXPORTS
|
||||
function
|
||||
alias == function
|
||||
data DATA
|
||||
constant CONSTANT
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
# RUN: lld-link /machine:x64 /def:%S/Inputs/library.def /out:%t.lib
|
||||
# RUN: llvm-nm %t.lib | FileCheck %s
|
||||
|
||||
CHECK: 00000000 a @comp.id
|
||||
CHECK: 00000000 a @feat.00
|
||||
CHECK: 00000000 W alias
|
||||
CHECK: U function
|
||||
|
||||
CHECK: 00000000 a @comp.id
|
||||
CHECK: 00000000 a @feat.00
|
||||
CHECK: 00000000 W __imp_alias
|
||||
CHECK: U __imp_function
|
||||
|
||||
CHECK: 00000000 R __imp_constant
|
||||
CHECK: 00000000 R constant
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue