[PATCH] D113819: [llvm-obcopy][MachO] Add error for MH_PRELOAD

Keith Smiley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 12 19:20:47 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG47bb456b2ffd: [llvm-obcopy][MachO] Add error for MH_PRELOAD (authored by keith).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113819/new/

https://reviews.llvm.org/D113819

Files:
  llvm/test/tools/llvm-objcopy/MachO/mh-preload-unsupported.yaml
  llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp


Index: llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
===================================================================
--- llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
+++ llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
@@ -389,6 +389,11 @@
   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));
 
Index: llvm/test/tools/llvm-objcopy/MachO/mh-preload-unsupported.yaml
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objcopy/MachO/mh-preload-unsupported.yaml
@@ -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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113819.386999.patch
Type: text/x-patch
Size: 1332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211113/f9d8fc23/attachment.bin>


More information about the llvm-commits mailing list