forked from OSchip/llvm-project
[llvm-obcopy][MachO] Add error for MH_PRELOAD
Previously this would crash. Fixes https://bugs.llvm.org/show_bug.cgi?id=51877 Differential Revision: https://reviews.llvm.org/D113819
This commit is contained in:
parent
9b29dae3ca
commit
47bb456b2f
|
@ -0,0 +1,16 @@
|
|||
--- !mach-o
|
||||
FileHeader:
|
||||
magic: 0xFEEDFACF
|
||||
cputype: 0x100000C
|
||||
cpusubtype: 0x0
|
||||
filetype: 0x5
|
||||
ncmds: 0
|
||||
sizeofcmds: 0
|
||||
flags: 0x1
|
||||
reserved: 0x0
|
||||
...
|
||||
|
||||
# RUN: yaml2obj %s > %t
|
||||
# RUN: not llvm-objcopy %t 2>&1 | FileCheck %s -DFILE=%t
|
||||
#
|
||||
# CHECK: error: [[FILE]]: MH_PRELOAD files are not supported
|
|
@ -389,6 +389,11 @@ Error objcopy::macho::executeObjcopyOnBinary(const CommonConfig &Config,
|
|||
if (!O)
|
||||
return createFileError(Config.InputFilename, O.takeError());
|
||||
|
||||
if (O->get()->Header.FileType == MachO::HeaderFileType::MH_PRELOAD)
|
||||
return createStringError(std::errc::not_supported,
|
||||
"%s: MH_PRELOAD files are not supported",
|
||||
Config.InputFilename.str().c_str());
|
||||
|
||||
if (Error E = handleArgs(Config, MachOConfig, **O))
|
||||
return createFileError(Config.InputFilename, std::move(E));
|
||||
|
||||
|
|
Loading…
Reference in New Issue