From fa552fc861d4e10cdfd989f60212299b6ee64f38 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 15 Dec 2016 19:37:46 +0000 Subject: [PATCH] LibDriver: Allow resource files to be archive members. It seems pointless to add a resource to an archive because it won't have any symbols to link against (and link.exe doesn't have an equivalent of --whole-archive), but lib.exe allows it for some reason. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289859 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/LibDriver/LibDriver.cpp | 6 ++++-- test/LibDriver/Inputs/resource.res | Bin 0 -> 108 bytes test/LibDriver/invalid.test | 2 +- test/LibDriver/resource.test | 3 +++ 4 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 test/LibDriver/Inputs/resource.res create mode 100644 test/LibDriver/resource.test diff --git a/lib/LibDriver/LibDriver.cpp b/lib/LibDriver/LibDriver.cpp index fa9f02c959d..bcdec4f7a93 100644 --- a/lib/LibDriver/LibDriver.cpp +++ b/lib/LibDriver/LibDriver.cpp @@ -146,8 +146,10 @@ int llvm::libDriverMain(llvm::ArrayRef ArgsArr) { sys::fs::file_magic Magic = sys::fs::identify_magic(MOrErr->Buf->getBuffer()); if (Magic != sys::fs::file_magic::coff_object && - Magic != sys::fs::file_magic::bitcode) { - llvm::errs() << Arg->getValue() << ": not a COFF object or bitcode file\n"; + Magic != sys::fs::file_magic::bitcode && + Magic != sys::fs::file_magic::windows_resource) { + llvm::errs() << Arg->getValue() + << ": not a COFF object, bitcode or resource file\n"; return 1; } Members.emplace_back(std::move(*MOrErr)); diff --git a/test/LibDriver/Inputs/resource.res b/test/LibDriver/Inputs/resource.res new file mode 100644 index 0000000000000000000000000000000000000000..f1c799fbbb08f4fe197f029008a1c54fd911fbfc GIT binary patch literal 108 zcmZQzU|>)H;{X347|28cT0oux5dZ(r2E>eDIRgPs7BB-$urhcsq%!0HVLn0-D+>Sx CaSE^i literal 0 HcmV?d00001 diff --git a/test/LibDriver/invalid.test b/test/LibDriver/invalid.test index 2a8b68cc60f..2978177a431 100644 --- a/test/LibDriver/invalid.test +++ b/test/LibDriver/invalid.test @@ -1,2 +1,2 @@ RUN: not llvm-lib %S/Inputs/cl-gl.obj 2>&1 | FileCheck %s -CHECK: not a COFF object or bitcode file +CHECK: not a COFF object, bitcode or resource file diff --git a/test/LibDriver/resource.test b/test/LibDriver/resource.test new file mode 100644 index 00000000000..6c3dad50b45 --- /dev/null +++ b/test/LibDriver/resource.test @@ -0,0 +1,3 @@ +RUN: llvm-lib /out:%t %S/Inputs/resource.res +RUN: llvm-ar t %t | FileCheck %s +CHECK: resource.res