[llvm] 6113998 - Add MachO MH_FILESET support to objdump
Peter Cooper via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 24 13:35:08 PDT 2022
Author: Peter Cooper
Date: 2022-08-24T13:34:43-07:00
New Revision: 611399806923e3e76a04e16bebb1fa7b85354346
URL: https://github.com/llvm/llvm-project/commit/611399806923e3e76a04e16bebb1fa7b85354346
DIFF: https://github.com/llvm/llvm-project/commit/611399806923e3e76a04e16bebb1fa7b85354346.diff
LOG: Add MachO MH_FILESET support to objdump
https://reviews.llvm.org/D131909
Added:
llvm/test/Object/AArch64/filetype-fileset.yaml
Modified:
llvm/include/llvm/BinaryFormat/Magic.h
llvm/lib/BinaryFormat/Magic.cpp
llvm/lib/Object/Binary.cpp
llvm/lib/Object/ObjectFile.cpp
llvm/lib/Object/SymbolicFile.cpp
llvm/tools/llvm-objdump/MachODump.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/BinaryFormat/Magic.h b/llvm/include/llvm/BinaryFormat/Magic.h
index c8e0dad42b0bc..329c96f5c14c4 100644
--- a/llvm/include/llvm/BinaryFormat/Magic.h
+++ b/llvm/include/llvm/BinaryFormat/Magic.h
@@ -40,6 +40,7 @@ struct file_magic {
macho_dsym_companion, ///< Mach-O dSYM companion file
macho_kext_bundle, ///< Mach-O kext bundle file
macho_universal_binary, ///< Mach-O universal binary
+ macho_file_set, ///< Mach-O file set binary
minidump, ///< Windows minidump file
coff_cl_gl_object, ///< Microsoft cl.exe's intermediate code file
coff_object, ///< COFF object file
diff --git a/llvm/lib/BinaryFormat/Magic.cpp b/llvm/lib/BinaryFormat/Magic.cpp
index 951668f68c0da..7a348f1df8503 100644
--- a/llvm/lib/BinaryFormat/Magic.cpp
+++ b/llvm/lib/BinaryFormat/Magic.cpp
@@ -182,6 +182,8 @@ file_magic llvm::identify_magic(StringRef Magic) {
return file_magic::macho_dsym_companion;
case 11:
return file_magic::macho_kext_bundle;
+ case 12:
+ return file_magic::macho_file_set;
}
break;
}
diff --git a/llvm/lib/Object/Binary.cpp b/llvm/lib/Object/Binary.cpp
index 8065e3eb1d852..d18aed8b3b8c8 100644
--- a/llvm/lib/Object/Binary.cpp
+++ b/llvm/lib/Object/Binary.cpp
@@ -67,6 +67,7 @@ Expected<std::unique_ptr<Binary>> object::createBinary(MemoryBufferRef Buffer,
case file_magic::macho_dynamically_linked_shared_lib_stub:
case file_magic::macho_dsym_companion:
case file_magic::macho_kext_bundle:
+ case file_magic::macho_file_set:
case file_magic::coff_object:
case file_magic::coff_import_library:
case file_magic::pecoff_executable:
diff --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp
index 1be8f11751beb..bc8e602f5a744 100644
--- a/llvm/lib/Object/ObjectFile.cpp
+++ b/llvm/lib/Object/ObjectFile.cpp
@@ -169,6 +169,7 @@ ObjectFile::createObjectFile(MemoryBufferRef Object, file_magic Type,
case file_magic::macho_dynamically_linked_shared_lib_stub:
case file_magic::macho_dsym_companion:
case file_magic::macho_kext_bundle:
+ case file_magic::macho_file_set:
return createMachOObjectFile(Object);
case file_magic::coff_object:
case file_magic::coff_import_library:
diff --git a/llvm/lib/Object/SymbolicFile.cpp b/llvm/lib/Object/SymbolicFile.cpp
index 05f47cfbf2ff3..e87ecb1491090 100644
--- a/llvm/lib/Object/SymbolicFile.cpp
+++ b/llvm/lib/Object/SymbolicFile.cpp
@@ -63,6 +63,7 @@ SymbolicFile::createSymbolicFile(MemoryBufferRef Object, file_magic Type,
case file_magic::macho_dynamically_linked_shared_lib_stub:
case file_magic::macho_dsym_companion:
case file_magic::macho_kext_bundle:
+ case file_magic::macho_file_set:
case file_magic::pecoff_executable:
case file_magic::xcoff_object_32:
case file_magic::xcoff_object_64:
@@ -113,6 +114,7 @@ bool SymbolicFile::isSymbolicFile(file_magic Type, const LLVMContext *Context) {
case file_magic::macho_dynamically_linked_shared_lib_stub:
case file_magic::macho_dsym_companion:
case file_magic::macho_kext_bundle:
+ case file_magic::macho_file_set:
case file_magic::pecoff_executable:
case file_magic::xcoff_object_32:
case file_magic::xcoff_object_64:
diff --git a/llvm/test/Object/AArch64/filetype-fileset.yaml b/llvm/test/Object/AArch64/filetype-fileset.yaml
new file mode 100644
index 0000000000000..0f9631ff076b2
--- /dev/null
+++ b/llvm/test/Object/AArch64/filetype-fileset.yaml
@@ -0,0 +1,18 @@
+# REQUIRES: host-byteorder-little-endian
+# RUN: yaml2obj %s \
+# RUN: | llvm-objdump --macho --private-header - 2>&1 \
+# RUN: | FileCheck %s
+
+# CHECK: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
+# CHECK-NEXT: MH_MAGIC_64 ARM64 ALL 0x00 FILESET 0 0 0x00000000
+
+--- !mach-o
+FileHeader:
+ magic: 0xFEEDFACF
+ cputype: 0x100000C
+ cpusubtype: 0x0
+ filetype: 0xC
+ ncmds: 0
+ sizeofcmds: 0
+ flags: 0x0
+ reserved: 0x0
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index de5e33ebcae98..31bb52a795c44 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -8599,6 +8599,9 @@ static void PrintMachHeader(uint32_t magic, uint32_t cputype,
case MachO::MH_KEXT_BUNDLE:
outs() << " KEXTBUNDLE";
break;
+ case MachO::MH_FILESET:
+ outs() << " FILESET";
+ break;
default:
outs() << format(" %10u", filetype);
break;
More information about the llvm-commits
mailing list