From 5530f234f52fb9167a6cc7ebf33e96e50a44a214 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 1 Aug 2018 22:31:31 +0000 Subject: [PATCH] Re-submit r338596 with a bug fix and a test. llvm-svn: 338647 --- lld/ELF/Driver.cpp | 11 ++++------- lld/test/ELF/oformat-binary.s | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 693dba64ab5a..76b338d178d7 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -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; } diff --git a/lld/test/ELF/oformat-binary.s b/lld/test/ELF/oformat-binary.s index e68f07c57732..22a25f04c64d 100644 --- a/lld/test/ELF/oformat-binary.s +++ b/lld/test/ELF/oformat-binary.s @@ -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