[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
This commit is contained in:
parent
2f5d6ae73f
commit
c141c8c59a
|
|
@ -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)>;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue