[PATCH] D105993: [SystemZ][z/OS] Add GOFF support to file magic identification

Anirudh Prasad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 15 10:06:05 PDT 2021


anirudhp updated this revision to Diff 359033.
anirudhp added a comment.

- Rebase on latest.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105993

Files:
  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/unittests/BinaryFormat/TestFileMagic.cpp


Index: llvm/unittests/BinaryFormat/TestFileMagic.cpp
===================================================================
--- llvm/unittests/BinaryFormat/TestFileMagic.cpp
+++ llvm/unittests/BinaryFormat/TestFileMagic.cpp
@@ -54,6 +54,8 @@
 const char coff_import_library[] = "\x00\x00\xff\xff....";
 const char elf_relocatable[] = {0x7f, 'E', 'L', 'F', 1, 2, 1, 0, 0,
                                 0,    0,   0,   0,   0, 0, 0, 0, 1};
+
+const char goff_object[] = "\x03\xF0\x00";
 const char macho_universal_binary[] = "\xca\xfe\xba\xbe...\x00";
 const char macho_object[] =
     "\xfe\xed\xfa\xce........\x00\x00\x00\x01............";
@@ -100,6 +102,7 @@
        file_magic::coff_object},
       DEFINE(coff_import_library),
       DEFINE(elf_relocatable),
+      DEFINE(goff_object),
       DEFINE(macho_universal_binary),
       DEFINE(macho_object),
       DEFINE(macho_executable),
Index: llvm/lib/Object/SymbolicFile.cpp
===================================================================
--- llvm/lib/Object/SymbolicFile.cpp
+++ llvm/lib/Object/SymbolicFile.cpp
@@ -53,6 +53,7 @@
   case file_magic::elf_executable:
   case file_magic::elf_shared_object:
   case file_magic::elf_core:
+  case file_magic::goff_object:
   case file_magic::macho_executable:
   case file_magic::macho_fixed_virtual_memory_shared_lib:
   case file_magic::macho_core:
@@ -102,6 +103,7 @@
   case file_magic::elf_executable:
   case file_magic::elf_shared_object:
   case file_magic::elf_core:
+  case file_magic::goff_object:
   case file_magic::macho_executable:
   case file_magic::macho_fixed_virtual_memory_shared_lib:
   case file_magic::macho_core:
Index: llvm/lib/Object/ObjectFile.cpp
===================================================================
--- llvm/lib/Object/ObjectFile.cpp
+++ llvm/lib/Object/ObjectFile.cpp
@@ -145,6 +145,7 @@
   case file_magic::windows_resource:
   case file_magic::pdb:
   case file_magic::minidump:
+  case file_magic::goff_object:
     return errorCodeToError(object_error::invalid_file_type);
   case file_magic::tapi_file:
     return errorCodeToError(object_error::invalid_file_type);
Index: llvm/lib/Object/Binary.cpp
===================================================================
--- llvm/lib/Object/Binary.cpp
+++ llvm/lib/Object/Binary.cpp
@@ -56,6 +56,7 @@
   case file_magic::elf_executable:
   case file_magic::elf_shared_object:
   case file_magic::elf_core:
+  case file_magic::goff_object:
   case file_magic::macho_object:
   case file_magic::macho_executable:
   case file_magic::macho_fixed_virtual_memory_shared_lib:
Index: llvm/lib/BinaryFormat/Magic.cpp
===================================================================
--- llvm/lib/BinaryFormat/Magic.cpp
+++ llvm/lib/BinaryFormat/Magic.cpp
@@ -71,6 +71,11 @@
       return file_magic::xcoff_object_64;
     break;
 
+  case 0x03:
+    if (startswith(Magic, "\x03\xF0\x00"))
+      return file_magic::goff_object;
+    break;
+
   case 0xDE: // 0x0B17C0DE = BC wraper
     if (startswith(Magic, "\xDE\xC0\x17\x0B"))
       return file_magic::bitcode;
Index: llvm/include/llvm/BinaryFormat/Magic.h
===================================================================
--- llvm/include/llvm/BinaryFormat/Magic.h
+++ llvm/include/llvm/BinaryFormat/Magic.h
@@ -27,6 +27,7 @@
     elf_executable,    ///< ELF Executable image
     elf_shared_object, ///< ELF dynamically linked shared lib
     elf_core,          ///< ELF core image
+    goff_object,       ///< GOFF object file
     macho_object,      ///< Mach-O Object file
     macho_executable,  ///< Mach-O Executable
     macho_fixed_virtual_memory_shared_lib,    ///< Mach-O Shared Lib, FVM


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105993.359033.patch
Type: text/x-patch
Size: 3655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210715/13b4620a/attachment.bin>


More information about the llvm-commits mailing list