diff options
| author | Kevin Enderby <enderby@apple.com> | 2016-01-26 23:43:37 +0000 |
|---|---|---|
| committer | Kevin Enderby <enderby@apple.com> | 2016-01-26 23:43:37 +0000 |
| commit | 87c85b7e23f3d87b0c8a8826e3ebc867fca7e7ae (patch) | |
| tree | fcc57d6c6144e54af650041845b208933c5e65b1 /llvm/unittests/Support | |
| parent | 8e785a4ec08cf7119b9e50688b2baa9123fd4ae8 (diff) | |
| download | bcm5719-llvm-87c85b7e23f3d87b0c8a8826e3ebc867fca7e7ae.tar.gz bcm5719-llvm-87c85b7e23f3d87b0c8a8826e3ebc867fca7e7ae.zip | |
Fix identify_magic() to check that a file that starts with MH_MAGIC is
at least as big as the mach header to be identified as a Mach-O file and
make sure smaller files are not identified as a Mach-O files but as
unknown files. Also fix identify_magic() so it looks at all 4 bytes of
the filetype field when determining the type of the Mach-O file.
Then fix the macho-invalid-header test case to check that it is an
unknown file and make sure it does not get the error for
object_error::parse_failed. And also update the unit tests.
llvm-svn: 258883
Diffstat (limited to 'llvm/unittests/Support')
| -rw-r--r-- | llvm/unittests/Support/Path.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index 3f626f87888..7bbac7ae9df 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -726,21 +726,29 @@ 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 macho_universal_binary[] = "\xca\xfe\xba\xbe...\0x00"; -const char macho_object[] = "\xfe\xed\xfa\xce..........\x00\x01"; -const char macho_executable[] = "\xfe\xed\xfa\xce..........\x00\x02"; +const char macho_object[] = + "\xfe\xed\xfa\xce........\x00\x00\x00\x01............"; +const char macho_executable[] = + "\xfe\xed\xfa\xce........\x00\x00\x00\x02............"; const char macho_fixed_virtual_memory_shared_lib[] = - "\xfe\xed\xfa\xce..........\x00\x03"; -const char macho_core[] = "\xfe\xed\xfa\xce..........\x00\x04"; -const char macho_preload_executable[] = "\xfe\xed\xfa\xce..........\x00\x05"; + "\xfe\xed\xfa\xce........\x00\x00\x00\x03............"; +const char macho_core[] = + "\xfe\xed\xfa\xce........\x00\x00\x00\x04............"; +const char macho_preload_executable[] = + "\xfe\xed\xfa\xce........\x00\x00\x00\x05............"; const char macho_dynamically_linked_shared_lib[] = - "\xfe\xed\xfa\xce..........\x00\x06"; -const char macho_dynamic_linker[] = "\xfe\xed\xfa\xce..........\x00\x07"; -const char macho_bundle[] = "\xfe\xed\xfa\xce..........\x00\x08"; -const char macho_dsym_companion[] = "\xfe\xed\xfa\xce..........\x00\x0a"; -const char macho_kext_bundle[] = "\xfe\xed\xfa\xce..........\x00\x0b"; + "\xfe\xed\xfa\xce........\x00\x00\x00\x06............"; +const char macho_dynamic_linker[] = + "\xfe\xed\xfa\xce........\x00\x00\x00\x07............"; +const char macho_bundle[] = + "\xfe\xed\xfa\xce........\x00\x00\x00\x08............"; +const char macho_dsym_companion[] = + "\xfe\xed\xfa\xce........\x00\x00\x00\x0a............"; +const char macho_kext_bundle[] = + "\xfe\xed\xfa\xce........\x00\x00\x00\x0b............"; const char windows_resource[] = "\x00\x00\x00\x00\x020\x00\x00\x00\xff"; const char macho_dynamically_linked_shared_lib_stub[] = - "\xfe\xed\xfa\xce..........\x00\x09"; + "\xfe\xed\xfa\xce........\x00\x00\x00\x09............"; TEST_F(FileSystemTest, Magic) { struct type { |

