File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
test/tools/llvm-objcopy/MachO Expand file tree Collapse file tree 2 files changed +37
-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 a non-Mach-O binary
6
+ # RUN: not llvm-install-name-tool -add_rpath foo %t 2>&1 | FileCheck %s --check-prefix=NON_MACH_O
7
+
8
+ # NON_MACH_O: llvm-install-name-tool: error: input file: {{.*}} is not a Mach-O file
9
+
10
+ --- !ELF
11
+ FileHeader:
12
+ Class: ELFCLASS64
13
+ Data: ELFDATA2LSB
14
+ Type: ET_EXEC
15
+ Machine: EM_X86_64
16
+ Sections:
17
+ - Name: .bss
18
+ Type: SHT_NOBITS
19
+ Flags: [ SHF_ALLOC ]
20
+ AddressAlign: 0x0000000000000010
21
+ Size: 64
22
+ - Name: .text
23
+ Type: SHT_PROGBITS
24
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
25
+ AddressAlign: 0x0000000000000010
26
+ Content: "00000000"
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"
@@ -1242,6 +1243,16 @@ objcopy::parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) {
1242
1243
Config.InputFilename = Positional[0 ];
1243
1244
Config.OutputFilename = Positional[0 ];
1244
1245
1246
+ Expected<llvm::object::OwningBinary<llvm::object::Binary>> BinaryOrErr =
1247
+ llvm::object::createBinary (Config.InputFilename );
1248
+ if (!BinaryOrErr)
1249
+ return createFileError (Config.InputFilename , BinaryOrErr.takeError ());
1250
+ auto *Binary = (*BinaryOrErr).getBinary ();
1251
+ if (!Binary->isMachO () && !Binary->isMachOUniversalBinary ())
1252
+ return createStringError (errc::invalid_argument,
1253
+ " input file: %s is not a Mach-O file" ,
1254
+ Config.InputFilename .str ().c_str ());
1255
+
1245
1256
DC.CopyConfigs .push_back (std::move (ConfigMgr));
1246
1257
return std::move (DC);
1247
1258
}
You can’t perform that action at this time.
0 commit comments