[lld] r205693 - [ELF] Fix driver bug.

Rui Ueyama ruiu at google.com
Sun Apr 6 14:15:05 PDT 2014


Author: ruiu
Date: Sun Apr  6 16:15:05 2014
New Revision: 205693

URL: http://llvm.org/viewvc/llvm-project?rev=205693&view=rev
Log:
[ELF] Fix driver bug.

GNU LD-comptaible driver wrongly requires a space after '=' for a few
options such as "-init=<symbol>" or "-entry=<symbol>". This patch is
to fix that bug and add a few tests for it.

Modified:
    lld/trunk/lib/Driver/GnuLdOptions.td
    lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp

Modified: lld/trunk/lib/Driver/GnuLdOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdOptions.td?rev=205693&r1=205692&r2=205693&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdOptions.td (original)
+++ lld/trunk/lib/Driver/GnuLdOptions.td Sun Apr  6 16:15:05 2014
@@ -7,12 +7,12 @@ include "llvm/Option/OptParser.td"
 multiclass smDash<string opt1, string opt2, string help> {
   // Option
   def "" : Separate<["-"], opt1>, HelpText<help>;
-  def opt1_eq : Separate<["-"], opt1#"=">,
+  def opt1_eq : Joined<["-"], opt1#"=">,
       Alias<!cast<Option>(opt1)>;
   // Compatibility aliases
   def opt2_dashdash : Separate<["--"], opt2>,
       Alias<!cast<Option>(opt1)>;
-  def opt2_dashdash_eq : Separate<["--"], opt2#"=">,
+  def opt2_dashdash_eq : Joined<["--"], opt2#"=">,
       Alias<!cast<Option>(opt1)>;
 }
 
@@ -21,7 +21,7 @@ multiclass dashEq<string opt1, string op
   // Option
   def "" : Separate<["-"], opt1>, HelpText<help>;
   // Compatibility aliases
-  def opt2_eq : Separate<["-"], opt2#"=">,
+  def opt2_eq : Joined<["-"], opt2#"=">,
       Alias<!cast<Option>(opt1)>;
 }
 

Modified: lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp?rev=205693&r1=205692&r2=205693&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp Sun Apr  6 16:15:05 2014
@@ -40,6 +40,43 @@ TEST_F(GnuLdParserTest, Empty) {
   EXPECT_EQ("No input files\n", errorMessage());
 }
 
+// --entry
+
+TEST_F(GnuLdParserTest, Entry) {
+  EXPECT_TRUE(parse("ld", "--start-group", "--end-group", "--entry", "foo",
+                    nullptr));
+  EXPECT_EQ("foo", _context->entrySymbolName());
+}
+
+TEST_F(GnuLdParserTest, EntryShort) {
+  EXPECT_TRUE(parse("ld", "--start-group", "--end-group", "-e", "foo",
+                    nullptr));
+  EXPECT_EQ("foo", _context->entrySymbolName());
+}
+
+TEST_F(GnuLdParserTest, EntryJoined) {
+  EXPECT_TRUE(parse("ld", "--start-group", "--end-group", "--entry=foo",
+                    nullptr));
+  EXPECT_EQ("foo", _context->entrySymbolName());
+}
+
+// --init
+
+TEST_F(GnuLdParserTest, Init) {
+  EXPECT_TRUE(parse("ld", "--start-group", "--end-group", "-init", "foo",
+                    "-init", "bar", nullptr));
+  EXPECT_EQ(2, _context->initFunctions().size());
+  EXPECT_EQ("foo", _context->initFunctions()[0]);
+  EXPECT_EQ("bar", _context->initFunctions()[1]);
+}
+
+TEST_F(GnuLdParserTest, InitJoined) {
+  EXPECT_TRUE(parse("ld", "--start-group", "--end-group", "-init=foo",
+                    nullptr));
+  EXPECT_EQ(1, _context->initFunctions().size());
+  EXPECT_EQ("foo", _context->initFunctions()[0]);
+}
+
 // --soname
 
 TEST_F(GnuLdParserTest, SOName) {





More information about the llvm-commits mailing list