[lld] r197122 - [PECOFF] Add /dllexport option.
Rui Ueyama
ruiu at google.com
Fri Dec 13 00:40:18 PST 2013
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. :)
On Fri, Dec 13, 2013 at 4:13 AM, Reid Kleckner <rnk at google.com> wrote:
> The commit message is off, but the implementation is right: the option is
> "/export" not "/dllexport". :)
>
>
> On Wed, Dec 11, 2013 at 7:11 PM, Rui Ueyama <ruiu at google.com> wrote:
>
>> Author: ruiu
>> Date: Wed Dec 11 21:11:26 2013
>> New Revision: 197122
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=197122&view=rev
>> Log:
>> [PECOFF] Add /dllexport option.
>>
>> /DLLEXPORT is a command line option to export a symbol.
>> __declspec(dllexport)
>> uses that to make the linker to export DLLExport'ed functions, by adding
>> the
>> option to .drectve section.
>>
>> This patch implements the parser of the command line option.
>>
>> Modified:
>> lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
>> lld/trunk/lib/Driver/WinLinkDriver.cpp
>> lld/trunk/lib/Driver/WinLinkOptions.td
>> lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
>>
>> Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=197122&r1=197121&r2=197122&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
>> +++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Wed Dec 11
>> 21:11:26 2013
>> @@ -219,6 +219,9 @@ public:
>> void setDosStub(ArrayRef<uint8_t> data) { _dosStub = data; }
>> ArrayRef<uint8_t> getDosStub() const { return _dosStub; }
>>
>> + void addDllExport(StringRef sym) { _dllExports.insert(sym); }
>> + const std::set<std::string> &getDllExports() const { return
>> _dllExports; }
>> +
>> StringRef allocate(StringRef ref) const {
>> char *x = _allocator.Allocate<char>(ref.size() + 1);
>> memcpy(x, ref.data(), ref.size());
>> @@ -297,6 +300,9 @@ private:
>> std::map<std::string, uint32_t> _sectionSetMask;
>> std::map<std::string, uint32_t> _sectionClearMask;
>>
>> + // DLLExport'ed symbols.
>> + std::set<std::string> _dllExports;
>> +
>> // List of files that will be removed on destruction.
>> std::vector<std::unique_ptr<llvm::FileRemover> > _tempFiles;
>>
>>
>> Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=197122&r1=197121&r2=197122&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
>> +++ lld/trunk/lib/Driver/WinLinkDriver.cpp Wed Dec 11 21:11:26 2013
>> @@ -832,6 +832,10 @@ WinLinkDriver::parse(int argc, const cha
>> ctx.setEntrySymbolName(ctx.allocate(inputArg->getValue()));
>> break;
>>
>> + case OPT_export:
>> + ctx.addDllExport(inputArg->getValue());
>> + break;
>> +
>> case OPT_libpath:
>> ctx.appendInputSearchPath(ctx.allocate(inputArg->getValue()));
>> break;
>>
>> Modified: lld/trunk/lib/Driver/WinLinkOptions.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkOptions.td?rev=197122&r1=197121&r2=197122&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/lib/Driver/WinLinkOptions.td (original)
>> +++ lld/trunk/lib/Driver/WinLinkOptions.td Wed Dec 11 21:11:26 2013
>> @@ -22,6 +22,7 @@ def nodefaultlib : P<"nodefaultlib", "Re
>> def disallowlib : Joined<["/", "-", "-?"], "disallowlib:">,
>> Alias<nodefaultlib>;
>> def entry : P<"entry", "Name of entry point symbol">;
>> // No help text because /failifmismatch is not intended to be used by
>> the user.
>> +def export : P<"export", "Export a function">;
>> def failifmismatch : P<"failifmismatch", "">;
>> def heap : P<"heap", "Size of the heap">;
>> def align : P<"align", "Section alignment">;
>>
>> Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=197122&r1=197121&r2=197122&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
>> +++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Wed Dec 11
>> 21:11:26 2013
>> @@ -155,6 +155,13 @@ TEST_F(WinLinkParserTest, AlternateName)
>> EXPECT_EQ("", _context.getAlternateName("foo"));
>> }
>>
>> +TEST_F(WinLinkParserTest, Export) {
>> + EXPECT_TRUE(parse("link.exe", "/export:_foo", "a.out", nullptr));
>> + const std::set<std::string> &exports = _context.getDllExports();
>> + EXPECT_TRUE(exports.count("_foo") == 1);
>> + EXPECT_TRUE(exports.count("nosuchsym") == 0);
>> +}
>> +
>> TEST_F(WinLinkParserTest, MachineX86) {
>> EXPECT_TRUE(parse("link.exe", "/machine:x86", "a.obj", nullptr));
>> EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_I386,
>> _context.getMachineType());
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131213/47e1e196/attachment.html>
More information about the llvm-commits
mailing list