From d7c4454fb20a07704d3110621b31e4286be930b8 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 20 Oct 2016 04:47:45 +0000 Subject: [PATCH] Fix error message for unknown -format argument. -format=, -format and -b are all the same. Previous code was intended to produce an error message with the same spelling as given from the command line, but it actually always printed out this string: "unknown -format= value:". This is probably more confusing than "unknown -format value:". So I changed the message. llvm-svn: 284693 --- lld/ELF/Driver.cpp | 7 +++---- lld/test/ELF/format-binary.test | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 15d30494b766..54a267fd6af0 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -581,13 +581,12 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { } // Returns a value of "-format" option. -static bool getBinaryOption(opt::Arg *Arg) { - StringRef S = Arg->getValue(); +static bool getBinaryOption(StringRef S) { if (S == "binary") return true; if (S == "elf" || S == "default") return false; - error("unknown " + Arg->getSpelling() + " format: " + S + + error("unknown -format value: " + S + " (supported formats: elf, default, binary)"); return false; } @@ -609,7 +608,7 @@ void LinkerDriver::createFiles(opt::InputArgList &Args) { Config->AsNeeded = true; break; case OPT_format: - Config->Binary = getBinaryOption(Arg); + Config->Binary = getBinaryOption(Arg->getValue()); break; case OPT_no_as_needed: Config->AsNeeded = false; diff --git a/lld/test/ELF/format-binary.test b/lld/test/ELF/format-binary.test index 132f77c9d998..586f5f963dfa 100644 --- a/lld/test/ELF/format-binary.test +++ b/lld/test/ELF/format-binary.test @@ -7,6 +7,10 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o # RUN: ld.lld %t.o -b binary %t.binary -b default %t.o -shared -o %t.out +# RUN: not ld.lld -b foo > %t.log 2>&1 +# RUN: FileCheck -check-prefix=ERR %s < %t.log +# ERR: error: unknown -format value: foo (supported formats: elf, default, binary) + # CHECK: Name: .data # CHECK-NEXT: Type: SHT_PROGBITS # CHECK-NEXT: Flags [