Re-submit r338596 with a bug fix and a test.

llvm-svn: 338647
This commit is contained in:
Rui Ueyama 2018-08-01 22:31:31 +00:00
parent 842bdd0071
commit 5530f234f5
2 changed files with 5 additions and 7 deletions

View File

@ -497,14 +497,11 @@ static Target2Policy getTarget2(opt::InputArgList &Args) {
}
static bool isOutputFormatBinary(opt::InputArgList &Args) {
if (auto *Arg = Args.getLastArg(OPT_oformat)) {
StringRef S = Arg->getValue();
if (S == "binary")
return true;
if (S.startswith("elf"))
return false;
StringRef S = Args.getLastArgValue(OPT_oformat, "elf");
if (S == "binary")
return true;
if (!S.startswith("elf"))
error("unknown --oformat value: " + S);
}
return false;
}

View File

@ -20,6 +20,7 @@
# ERR: unknown --oformat value: foo
# RUN: ld.lld -o /dev/null %t --oformat elf
# RUN: ld.lld -o /dev/null %t --oformat elf-foo
.text
.align 4