summaryrefslogtreecommitdiffstats
path: root/lld/unittests/DriverTests
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-04-06 21:15:05 +0000
committerRui Ueyama <ruiu@google.com>2014-04-06 21:15:05 +0000
commitc141c8c59ad90c0ca4e65294e85dea2f3074bf4d (patch)
tree682eaa90b8daf157fccb8418083c4a62d76822c9 /lld/unittests/DriverTests
parent2f5d6ae73fa4b810be69b2b6e421600d0872be43 (diff)
downloadbcm5719-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/unittests/DriverTests')
-rw-r--r--lld/unittests/DriverTests/GnuLdDriverTest.cpp37
1 files changed, 37 insertions, 0 deletions
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) {
OpenPOWER on IntegriCloud