From 2b68ada188d0e850875a0ebf6939276fd21a71b4 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Thu, 8 Sep 2016 19:36:22 +0000 Subject: [PATCH] ELF: Report original emulation name in "unknown emulation" error A trailing _fbsd is stripped from emulation names, but if the result was still not a valid emulation the error was somewhat confusing. For example, % ld.lld -m elf_amd64_fbsd unknown emulation: elf_amd64 Use the original emulation name in error messages. Differential Revision: https://reviews.llvm.org/D24357 llvm-svn: 280983 --- lld/ELF/Driver.cpp | 7 ++++--- lld/test/ELF/basic.s | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index d238f37..a486873 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -54,7 +54,8 @@ bool elf::link(ArrayRef Args, raw_ostream &Error) { } // Parses a linker -m option. -static std::pair parseEmulation(StringRef S) { +static std::pair parseEmulation(StringRef Emul) { + StringRef S = Emul; if (S.endswith("_fbsd")) S = S.drop_back(5); @@ -78,9 +79,9 @@ static std::pair parseEmulation(StringRef S) { if (Ret.first == ELFNoneKind) { if (S == "i386pe" || S == "i386pep" || S == "thumb2pe") - error("Windows targets are not supported on the ELF frontend: " + S); + error("Windows targets are not supported on the ELF frontend: " + Emul); else - error("unknown emulation: " + S); + error("unknown emulation: " + Emul); } return Ret; } diff --git a/lld/test/ELF/basic.s b/lld/test/ELF/basic.s index 2844933..e9e1b3a 100644 --- a/lld/test/ELF/basic.s +++ b/lld/test/ELF/basic.s @@ -223,8 +223,8 @@ _start: # RUN: not ld.lld %t %t -o %t2 2>&1 | FileCheck --check-prefix=DUP %s # DUP: duplicate symbol: _start in {{.*}} and {{.*}} -# RUN: not ld.lld %t -o %t -m wrong_emul 2>&1 | FileCheck --check-prefix=UNKNOWN_EMUL %s -# UNKNOWN_EMUL: unknown emulation: wrong_emul +# RUN: not ld.lld %t -o %t -m wrong_emul_fbsd 2>&1 | FileCheck --check-prefix=UNKNOWN_EMUL %s +# UNKNOWN_EMUL: unknown emulation: wrong_emul_fbsd # RUN: not ld.lld %t --lto-jobs=0 2>&1 | FileCheck --check-prefix=NOTHREADS %s # NOTHREADS: number of threads must be > 0 -- 2.7.4