[lld] r207827 - [PECOFF] Support =internalName syntax in .def file.
Rui Ueyama
ruiu at google.com
Thu May 1 20:43:51 PDT 2014
Author: ruiu
Date: Thu May 1 22:43:51 2014
New Revision: 207827
URL: http://llvm.org/viewvc/llvm-project?rev=207827&view=rev
Log:
[PECOFF] Support =internalName syntax in .def file.
Export definitions in a module definition file is as follows:
exportedname[=internalname] [@ordinal [NONAME]] [PRIVATE] [DATA]
Previously we did not support =internalname, so users couldn't export
symbols from a DLL with a different name.
Modified:
lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
lld/trunk/lib/Driver/WinLinkModuleDef.cpp
lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp
lld/trunk/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp
lld/trunk/test/pecoff/Inputs/export.obj.yaml
lld/trunk/test/pecoff/Inputs/exports.def
lld/trunk/test/pecoff/export.test
Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=207827&r1=207826&r2=207827&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Thu May 1 22:43:51 2014
@@ -67,7 +67,7 @@ public:
}
std::string name;
- std::string internalName;
+ std::string externalName;
int ordinal;
bool noname;
bool isData;
Modified: lld/trunk/lib/Driver/WinLinkModuleDef.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkModuleDef.cpp?rev=207827&r1=207826&r2=207827&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkModuleDef.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkModuleDef.cpp Thu May 1 22:43:51 2014
@@ -195,6 +195,17 @@ bool Parser::parseExport(PECOFFLinkingCo
}
result.name = _tok._range;
+ consumeToken();
+ if (_tok._kind == Kind::equal) {
+ consumeToken();
+ if (_tok._kind != Kind::identifier)
+ return false;
+ result.externalName = result.name;
+ result.name = _tok._range;
+ } else {
+ ungetToken();
+ }
+
for (;;) {
consumeToken();
if (_tok._kind == Kind::identifier && _tok._range[0] == '@') {
Modified: lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp?rev=207827&r1=207826&r2=207827&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.cpp Thu May 1 22:43:51 2014
@@ -77,7 +77,8 @@ static bool getExportedAtoms(PECOFFLinki
}
const DefinedAtom *atom = it->second;
ret.push_back(TableEntry(desc.name, desc.ordinal, atom, desc.noname));
- desc.internalName = removeLeadingUnderscore(atom->name());
+ if (desc.externalName.empty())
+ desc.externalName = removeLeadingUnderscore(atom->name());
exports.insert(desc);
}
ctx.getDllExports().swap(exports);
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp?rev=207827&r1=207826&r2=207827&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterImportLibrary.cpp Thu May 1 22:43:51 2014
@@ -30,7 +30,7 @@ createModuleDefinitionFile(const PECOFFL
<< "EXPORTS\n";
for (const PECOFFLinkingContext::ExportDesc &desc : ctx.getDllExports()) {
- os << " " << desc.internalName << " @" << desc.ordinal;
+ os << " " << desc.externalName << " @" << desc.ordinal;
if (desc.noname)
os << " NONAME";
if (desc.isData)
Modified: lld/trunk/test/pecoff/Inputs/export.obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/export.obj.yaml?rev=207827&r1=207826&r2=207827&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/export.obj.yaml (original)
+++ lld/trunk/test/pecoff/Inputs/export.obj.yaml Thu May 1 22:43:51 2014
@@ -48,4 +48,10 @@ symbols:
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: _exportfn6
+ Value: 16
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
...
Modified: lld/trunk/test/pecoff/Inputs/exports.def
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/exports.def?rev=207827&r1=207826&r2=207827&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/exports.def (original)
+++ lld/trunk/test/pecoff/Inputs/exports.def Thu May 1 22:43:51 2014
@@ -3,3 +3,4 @@
EXPORTS
exportfn1 @5 ; foo
exportfn2
+ exportfn5=exportfn6
Modified: lld/trunk/test/pecoff/export.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/export.test?rev=207827&r1=207826&r2=207827&view=diff
==============================================================================
--- lld/trunk/test/pecoff/export.test (original)
+++ lld/trunk/test/pecoff/export.test Thu May 1 22:43:51 2014
@@ -39,4 +39,5 @@ CHECK4: DLL name: export.test.tmp4.
CHECK4: Ordinal RVA Name
CHECK4-NEXT: 5 0x2008 exportfn1
CHECK4-NEXT: 6 0x2010 exportfn2
-CHECK4-NEXT: 7 0x2010 exportfn3 at 256
+CHECK4-NEXT: 7 0x2010 exportfn6
+CHECK4-NEXT: 8 0x2010 exportfn3 at 256
More information about the llvm-commits
mailing list