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) { static bool isOutputFormatBinary(opt::InputArgList &Args) {
if (auto *Arg = Args.getLastArg(OPT_oformat)) { StringRef S = Args.getLastArgValue(OPT_oformat, "elf");
StringRef S = Arg->getValue(); if (S == "binary")
if (S == "binary") return true;
return true; if (!S.startswith("elf"))
if (S.startswith("elf"))
return false;
error("unknown --oformat value: " + S); error("unknown --oformat value: " + S);
}
return false; return false;
} }

View File

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