From 2050b6145113246ea3bb43725ad650c141eff998 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 10 Feb 2015 21:27:31 +0000 Subject: [PATCH] GNU: Add --no-export-dynamic command line option. llvm-svn: 228749 --- lld/lib/Driver/GnuLdDriver.cpp | 5 +++-- lld/lib/Driver/GnuLdOptions.td | 2 ++ lld/unittests/DriverTests/GnuLdDriverTest.cpp | 12 ++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lld/lib/Driver/GnuLdDriver.cpp b/lld/lib/Driver/GnuLdDriver.cpp index da1675a61d3f..326e2baaac4a 100644 --- a/lld/lib/Driver/GnuLdDriver.cpp +++ b/lld/lib/Driver/GnuLdDriver.cpp @@ -508,8 +508,9 @@ bool GnuLdDriver::parse(int argc, const char *argv[], if (parsedArgs->hasArg(OPT_noinhibit_exec)) ctx->setAllowRemainingUndefines(true); - if (parsedArgs->hasArg(OPT_export_dynamic)) - ctx->setExportDynamic(true); + if (auto val = getBool(*parsedArgs, OPT_export_dynamic, + OPT_no_export_dynamic)) + ctx->setExportDynamic(*val); if (parsedArgs->hasArg(OPT_allow_multiple_definition)) ctx->setAllowDuplicates(true); diff --git a/lld/lib/Driver/GnuLdOptions.td b/lld/lib/Driver/GnuLdOptions.td index 6f22150cc599..18c1a0d5280d 100644 --- a/lld/lib/Driver/GnuLdOptions.td +++ b/lld/lib/Driver/GnuLdOptions.td @@ -156,6 +156,8 @@ def export_dynamic : Flag<["-", "--"], "export-dynamic">, Group; def alias_export_dynamic: Flag<["-"], "E">, Alias; +def no_export_dynamic : Flag<["--"], "no-export-dynamic">, + Group; //===----------------------------------------------------------------------===// /// Dynamic Library Options diff --git a/lld/unittests/DriverTests/GnuLdDriverTest.cpp b/lld/unittests/DriverTests/GnuLdDriverTest.cpp index 36d56258b6f2..a736f5cee2a5 100644 --- a/lld/unittests/DriverTests/GnuLdDriverTest.cpp +++ b/lld/unittests/DriverTests/GnuLdDriverTest.cpp @@ -91,6 +91,18 @@ TEST_F(GnuLdParserTest, EntryJoined) { EXPECT_EQ("foo", _context->entrySymbolName()); } +// --export-dynamic + +TEST_F(GnuLdParserTest, ExportDynamic) { + EXPECT_TRUE(parse("ld", "a.o", "--export-dynamic", nullptr)); + EXPECT_TRUE(_context->shouldExportDynamic()); +} + +TEST_F(GnuLdParserTest, NoExportDynamic) { + EXPECT_TRUE(parse("ld", "a.o", "--no-export-dynamic", nullptr)); + EXPECT_FALSE(_context->shouldExportDynamic()); +} + // --init TEST_F(GnuLdParserTest, Init) {