Skip to content

Commit

Permalink
Add MachO MH_FILESET support to objdump
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperp committed Aug 24, 2022
1 parent 8f45b5a commit 6113998
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions llvm/include/llvm/BinaryFormat/Magic.h
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/BinaryFormat/Magic.cpp
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Object/Binary.cpp
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Object/ObjectFile.cpp
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Object/SymbolicFile.cpp
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
18 changes: 18 additions & 0 deletions 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
3 changes: 3 additions & 0 deletions llvm/tools/llvm-objdump/MachODump.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 6113998

Please sign in to comment.