[lld] r235895 - ELF: Simplify LinkerScript detection. NFC.
Rui Ueyama
ruiu at google.com
Mon Apr 27 09:54:48 PDT 2015
Author: ruiu
Date: Mon Apr 27 11:54:48 2015
New Revision: 235895
URL: http://llvm.org/viewvc/llvm-project?rev=235895&view=rev
Log:
ELF: Simplify LinkerScript detection. NFC.
Modified:
lld/trunk/lib/Driver/GnuLdDriver.cpp
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=235895&r1=235894&r2=235895&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Mon Apr 27 11:54:48 2015
@@ -112,22 +112,6 @@ maybeExpandResponseFiles(int argc, const
return std::make_tuple(argc, copy);
}
-static std::error_code
-getFileMagic(StringRef path, llvm::sys::fs::file_magic &magic) {
- std::error_code ec = llvm::sys::fs::identify_magic(path, magic);
- if (ec)
- return ec;
- switch (magic) {
- case llvm::sys::fs::file_magic::archive:
- case llvm::sys::fs::file_magic::elf_relocatable:
- case llvm::sys::fs::file_magic::elf_shared_object:
- case llvm::sys::fs::file_magic::unknown:
- return std::error_code();
- default:
- return make_dynamic_error_code("unknown type of object file");
- }
-}
-
// Parses an argument of --defsym=<sym>=<number>
static bool parseDefsymAsAbsolute(StringRef opt, StringRef &sym,
uint64_t &addr) {
@@ -214,9 +198,9 @@ getArchType(const llvm::Triple &triple,
static bool isLinkerScript(StringRef path, raw_ostream &diag) {
llvm::sys::fs::file_magic magic = llvm::sys::fs::file_magic::unknown;
- std::error_code ec = getFileMagic(path, magic);
- if (ec) {
- diag << "unknown input file format for file " << path << "\n";
+ if (std::error_code ec = llvm::sys::fs::identify_magic(path, magic)) {
+ diag << "unknown input file format: " << path << ": "
+ << ec.message() << "\n";
return false;
}
return magic == llvm::sys::fs::file_magic::unknown;
More information about the llvm-commits
mailing list