diff options
author | Rui Ueyama <ruiu@google.com> | 2014-04-06 21:15:05 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2014-04-06 21:15:05 +0000 |
commit | c141c8c59ad90c0ca4e65294e85dea2f3074bf4d (patch) | |
tree | 682eaa90b8daf157fccb8418083c4a62d76822c9 /lld | |
parent | 2f5d6ae73fa4b810be69b2b6e421600d0872be43 (diff) | |
download | bcm5719-llvm-c141c8c59ad90c0ca4e65294e85dea2f3074bf4d.tar.gz bcm5719-llvm-c141c8c59ad90c0ca4e65294e85dea2f3074bf4d.zip |
[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.
llvm-svn: 205693
Diffstat (limited to 'lld')
-rw-r--r-- | lld/lib/Driver/GnuLdOptions.td | 6 | ||||
-rw-r--r-- | lld/unittests/DriverTests/GnuLdDriverTest.cpp | 37 |
2 files changed, 40 insertions, 3 deletions
diff --git a/lld/lib/Driver/GnuLdOptions.td b/lld/lib/Driver/GnuLdOptions.td index e4166dfe5ba..4c8d8f5901a 100644 --- a/lld/lib/Driver/GnuLdOptions.td +++ b/lld/lib/Driver/GnuLdOptions.td @@ -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 opt2, string help> { // Option def "" : Separate<["-"], opt1>, HelpText<help>; // Compatibility aliases - def opt2_eq : Separate<["-"], opt2#"=">, + def opt2_eq : Joined<["-"], opt2#"=">, Alias<!cast<Option>(opt1)>; } diff --git a/lld/unittests/DriverTests/GnuLdDriverTest.cpp b/lld/unittests/DriverTests/GnuLdDriverTest.cpp index 3e01a032a16..f1b63904e62 100644 --- a/lld/unittests/DriverTests/GnuLdDriverTest.cpp +++ b/lld/unittests/DriverTests/GnuLdDriverTest.cpp @@ -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) { |