Support ELF files of unknown type.

llvm-svn: 222208
This commit is contained in:
Michael J. Spencer 2014-11-18 01:14:25 +00:00
parent ea508635de
commit bbd875b6ad
5 changed files with 7 additions and 0 deletions

View File

@ -226,6 +226,7 @@ struct file_magic {
unknown = 0, ///< Unrecognized file unknown = 0, ///< Unrecognized file
bitcode, ///< Bitcode file bitcode, ///< Bitcode file
archive, ///< ar style archive file archive, ///< ar style archive file
elf, ///< ELF Unknown type
elf_relocatable, ///< ELF Relocatable object file elf_relocatable, ///< ELF Relocatable object file
elf_executable, ///< ELF Executable image elf_executable, ///< ELF Executable image
elf_shared_object, ///< ELF dynamically linked shared lib elf_shared_object, ///< ELF dynamically linked shared lib

View File

@ -43,6 +43,7 @@ ErrorOr<std::unique_ptr<Binary>> object::createBinary(MemoryBufferRef Buffer,
switch (Type) { switch (Type) {
case sys::fs::file_magic::archive: case sys::fs::file_magic::archive:
return Archive::create(Buffer); return Archive::create(Buffer);
case sys::fs::file_magic::elf:
case sys::fs::file_magic::elf_relocatable: case sys::fs::file_magic::elf_relocatable:
case sys::fs::file_magic::elf_executable: case sys::fs::file_magic::elf_executable:
case sys::fs::file_magic::elf_shared_object: case sys::fs::file_magic::elf_shared_object:

View File

@ -60,6 +60,7 @@ ObjectFile::createObjectFile(MemoryBufferRef Object, sys::fs::file_magic Type) {
case sys::fs::file_magic::macho_universal_binary: case sys::fs::file_magic::macho_universal_binary:
case sys::fs::file_magic::windows_resource: case sys::fs::file_magic::windows_resource:
return object_error::invalid_file_type; return object_error::invalid_file_type;
case sys::fs::file_magic::elf:
case sys::fs::file_magic::elf_relocatable: case sys::fs::file_magic::elf_relocatable:
case sys::fs::file_magic::elf_executable: case sys::fs::file_magic::elf_executable:
case sys::fs::file_magic::elf_shared_object: case sys::fs::file_magic::elf_shared_object:

View File

@ -40,6 +40,7 @@ ErrorOr<std::unique_ptr<SymbolicFile>> SymbolicFile::createSymbolicFile(
case sys::fs::file_magic::macho_universal_binary: case sys::fs::file_magic::macho_universal_binary:
case sys::fs::file_magic::windows_resource: case sys::fs::file_magic::windows_resource:
return object_error::invalid_file_type; return object_error::invalid_file_type;
case sys::fs::file_magic::elf:
case sys::fs::file_magic::elf_executable: case sys::fs::file_magic::elf_executable:
case sys::fs::file_magic::elf_shared_object: case sys::fs::file_magic::elf_shared_object:
case sys::fs::file_magic::elf_core: case sys::fs::file_magic::elf_core:

View File

@ -958,6 +958,9 @@ file_magic identify_magic(StringRef Magic) {
case 3: return file_magic::elf_shared_object; case 3: return file_magic::elf_shared_object;
case 4: return file_magic::elf_core; case 4: return file_magic::elf_core;
} }
else
// It's still some type of ELF file.
return file_magic::elf;
} }
break; break;