File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
test/tools/llvm-objcopy/MachO Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ ## This test checks general llvm-install-name-tool behavior.
2
+
3
+ # RUN: yaml2obj %s -o %t
4
+
5
+ ## Passing something that doesn't exist
6
+ # RUN: not llvm-install-name-tool -add_rpath foo non-existent-binary 2>&1 | FileCheck %s --check-prefix=DOES_NOT_EXIST
7
+
8
+ # DOES_NOT_EXIST: {{.*}}non-existent-binary
9
+
10
+ ## Passing a non-Mach-O binary
11
+ # RUN: not llvm-install-name-tool -add_rpath foo %t 2>&1 | FileCheck %s --check-prefix=NON_MACH_O -DFILE=%t
12
+
13
+ # NON_MACH_O: error: input file: [[FILE]] is not a Mach-O file
14
+
15
+ --- !ELF
16
+ FileHeader:
17
+ Class: ELFCLASS64
18
+ Data: ELFDATA2LSB
19
+ Type: ET_EXEC
Original file line number Diff line number Diff line change 15
15
#include " llvm/ObjCopy/CommonConfig.h"
16
16
#include " llvm/ObjCopy/ConfigManager.h"
17
17
#include " llvm/ObjCopy/MachO/MachOConfig.h"
18
+ #include " llvm/Object/Binary.h"
18
19
#include " llvm/Option/Arg.h"
19
20
#include " llvm/Option/ArgList.h"
20
21
#include " llvm/Support/CRC.h"
26
27
27
28
using namespace llvm ;
28
29
using namespace llvm ::objcopy;
30
+ using namespace llvm ::object;
29
31
using namespace llvm ::opt;
30
32
31
33
namespace {
@@ -1242,6 +1244,16 @@ objcopy::parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) {
1242
1244
Config.InputFilename = Positional[0 ];
1243
1245
Config.OutputFilename = Positional[0 ];
1244
1246
1247
+ Expected<OwningBinary<Binary>> BinaryOrErr =
1248
+ createBinary (Config.InputFilename );
1249
+ if (!BinaryOrErr)
1250
+ return createFileError (Config.InputFilename , BinaryOrErr.takeError ());
1251
+ auto *Binary = (*BinaryOrErr).getBinary ();
1252
+ if (!Binary->isMachO () && !Binary->isMachOUniversalBinary ())
1253
+ return createStringError (errc::invalid_argument,
1254
+ " input file: %s is not a Mach-O file" ,
1255
+ Config.InputFilename .str ().c_str ());
1256
+
1245
1257
DC.CopyConfigs .push_back (std::move (ConfigMgr));
1246
1258
return std::move (DC);
1247
1259
}
You can’t perform that action at this time.
0 commit comments