<div dir="ltr">Oh, that's right. I was trying to avoid using word "export" as an identifier when I was writing this patch as it's a keyword, and accidentally did the same thing for the commit message. :)</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Dec 13, 2013 at 4:13 AM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">The commit message is off, but the implementation is right: the option is "/export" not "/dllexport". :)</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Dec 11, 2013 at 7:11 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Wed Dec 11 21:11:26 2013<br>
New Revision: 197122<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=197122&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=197122&view=rev</a><br>
Log:<br>
[PECOFF] Add /dllexport option.<br>
<br>
/DLLEXPORT is a command line option to export a symbol. __declspec(dllexport)<br>
uses that to make the linker to export DLLExport'ed functions, by adding the<br>
option to .drectve section.<br>
<br>
This patch implements the parser of the command line option.<br>
<br>
Modified:<br>
lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h<br>
lld/trunk/lib/Driver/WinLinkDriver.cpp<br>
lld/trunk/lib/Driver/WinLinkOptions.td<br>
lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp<br>
<br>
Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=197122&r1=197121&r2=197122&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=197122&r1=197121&r2=197122&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)<br>
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Wed Dec 11 21:11:26 2013<br>
@@ -219,6 +219,9 @@ public:<br>
void setDosStub(ArrayRef<uint8_t> data) { _dosStub = data; }<br>
ArrayRef<uint8_t> getDosStub() const { return _dosStub; }<br>
<br>
+ void addDllExport(StringRef sym) { _dllExports.insert(sym); }<br>
+ const std::set<std::string> &getDllExports() const { return _dllExports; }<br>
+<br>
StringRef allocate(StringRef ref) const {<br>
char *x = _allocator.Allocate<char>(ref.size() + 1);<br>
memcpy(x, ref.data(), ref.size());<br>
@@ -297,6 +300,9 @@ private:<br>
std::map<std::string, uint32_t> _sectionSetMask;<br>
std::map<std::string, uint32_t> _sectionClearMask;<br>
<br>
+ // DLLExport'ed symbols.<br>
+ std::set<std::string> _dllExports;<br>
+<br>
// List of files that will be removed on destruction.<br>
std::vector<std::unique_ptr<llvm::FileRemover> > _tempFiles;<br>
<br>
<br>
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=197122&r1=197121&r2=197122&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=197122&r1=197121&r2=197122&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)<br>
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Wed Dec 11 21:11:26 2013<br>
@@ -832,6 +832,10 @@ WinLinkDriver::parse(int argc, const cha<br>
ctx.setEntrySymbolName(ctx.allocate(inputArg->getValue()));<br>
break;<br>
<br>
+ case OPT_export:<br>
+ ctx.addDllExport(inputArg->getValue());<br>
+ break;<br>
+<br>
case OPT_libpath:<br>
ctx.appendInputSearchPath(ctx.allocate(inputArg->getValue()));<br>
break;<br>
<br>
Modified: lld/trunk/lib/Driver/WinLinkOptions.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkOptions.td?rev=197122&r1=197121&r2=197122&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkOptions.td?rev=197122&r1=197121&r2=197122&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Driver/WinLinkOptions.td (original)<br>
+++ lld/trunk/lib/Driver/WinLinkOptions.td Wed Dec 11 21:11:26 2013<br>
@@ -22,6 +22,7 @@ def nodefaultlib : P<"nodefaultlib", "Re<br>
def disallowlib : Joined<["/", "-", "-?"], "disallowlib:">, Alias<nodefaultlib>;<br>
def entry : P<"entry", "Name of entry point symbol">;<br>
// No help text because /failifmismatch is not intended to be used by the user.<br>
+def export : P<"export", "Export a function">;<br>
def failifmismatch : P<"failifmismatch", "">;<br>
def heap : P<"heap", "Size of the heap">;<br>
def align : P<"align", "Section alignment">;<br>
<br>
Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=197122&r1=197121&r2=197122&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=197122&r1=197121&r2=197122&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)<br>
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Wed Dec 11 21:11:26 2013<br>
@@ -155,6 +155,13 @@ TEST_F(WinLinkParserTest, AlternateName)<br>
EXPECT_EQ("", _context.getAlternateName("foo"));<br>
}<br>
<br>
+TEST_F(WinLinkParserTest, Export) {<br>
+ EXPECT_TRUE(parse("link.exe", "/export:_foo", "a.out", nullptr));<br>
+ const std::set<std::string> &exports = _context.getDllExports();<br>
+ EXPECT_TRUE(exports.count("_foo") == 1);<br>
+ EXPECT_TRUE(exports.count("nosuchsym") == 0);<br>
+}<br>
+<br>
TEST_F(WinLinkParserTest, MachineX86) {<br>
EXPECT_TRUE(parse("link.exe", "/machine:x86", "a.obj", nullptr));<br>
EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_I386, _context.getMachineType());<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>