1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 10:32:48 +02:00

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

- This patch adds in the GOFF format to the file magic identification logic in LLVM
- Currently, for the object file support, GOFF is marked as having as an error
- However, this is only temporary until https://reviews.llvm.org/D98437 is merged in

Reviewed By: abhina.sreeskantharajan

Differential Revision: https://reviews.llvm.org/D105993
This commit is contained in:
Anirudh Prasad 2021-07-20 10:50:18 -04:00
parent 41db4b6343
commit 0dda2de3a7
6 changed files with 13 additions and 0 deletions

View File

@ -27,6 +27,7 @@ struct file_magic {
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

View File

@ -71,6 +71,11 @@ file_magic llvm::identify_magic(StringRef Magic) {
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;

View File

@ -56,6 +56,7 @@ Expected<std::unique_ptr<Binary>> object::createBinary(MemoryBufferRef Buffer,
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:

View File

@ -145,6 +145,7 @@ ObjectFile::createObjectFile(MemoryBufferRef Object, file_magic Type,
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);

View File

@ -53,6 +53,7 @@ SymbolicFile::createSymbolicFile(MemoryBufferRef Object, file_magic Type,
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 @@ bool SymbolicFile::isSymbolicFile(file_magic Type, const LLVMContext *Context) {
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:

View File

@ -54,6 +54,8 @@ const char coff_bigobj[] =
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 @@ TEST_F(MagicTest, Magic) {
file_magic::coff_object},
DEFINE(coff_import_library),
DEFINE(elf_relocatable),
DEFINE(goff_object),
DEFINE(macho_universal_binary),
DEFINE(macho_object),
DEFINE(macho_executable),