[PATCH] D113365: [LLD][COFF] Support GNU style == aliases
Ayke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 7 07:58:56 PST 2021
aykevl created this revision.
aykevl added reviewers: mstorsjo, rnk.
Herald added a subscriber: jeroen.dobbelaere.
aykevl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
D46245 <https://reviews.llvm.org/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`).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113365
Files:
lld/COFF/Config.h
lld/COFF/Driver.cpp
lld/test/COFF/Inputs/library.def
lld/test/COFF/lib.test
Index: lld/test/COFF/lib.test
===================================================================
--- lld/test/COFF/lib.test
+++ lld/test/COFF/lib.test
@@ -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
Index: lld/test/COFF/Inputs/library.def
===================================================================
--- lld/test/COFF/Inputs/library.def
+++ lld/test/COFF/Inputs/library.def
@@ -1,5 +1,6 @@
LIBRARY library
EXPORTS
function
+ alias == function
data DATA
constant CONSTANT
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -815,6 +815,7 @@
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;
@@ -913,6 +914,7 @@
}
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;
Index: lld/COFF/Config.h
===================================================================
--- lld/COFF/Config.h
+++ lld/COFF/Config.h
@@ -43,6 +43,7 @@
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 @@
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113365.385345.patch
Type: text/x-patch
Size: 2220 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211107/695f18b1/attachment.bin>
More information about the llvm-commits
mailing list