1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/Object
Kevin Enderby 9b924af8f7 Fix the code that leads to the incorrect trigger of the report_fatal_error()
in MachOObjectFile::getSymbolByIndex() when a Mach-O file has
a symbol table load command but the number of symbols are zero.

The code in MachOObjectFile::symbol_begin_impl() should not be
assuming there is a symbol at index 0, in cases there is no symbol
table load command or the count of symbol is zero.  So I also fixed
that.  And needed to fix MachOObjectFile::symbol_end_impl() to
also do the same thing for no symbol table or one with zero entries.

The code in MachOObjectFile::getSymbolByIndex() should trigger
the report_fatal_error() for programmatic errors for any index when
there is no symbol table load command and not return the end iterator.
So also fixed that. Note there is no test case as this is a programmatic
error.

The test case using the file macho-invalid-bad-symbol-index has
a symbol table load command with its number of symbols (nsyms)
is zero. Which was incorrectly testing the bad triggering of the
report_fatal_error() in in MachOObjectFile::getSymbolByIndex().

This test case is an invalid Mach-O file but not for that reason.
It appears this Mach-O file use to have an nsyms value of 11,
and what makes this Mach-O file invalid is the counts and
indexes into the symbol table of the dynamic load command
are now invalid because the number of symbol table entries
(nsyms) is now zero.  Which can be seen with the existing
llvm-obdump:

% llvm-objdump -private-headers macho-invalid-bad-symbol-index
…
Load command 4
     cmd LC_SYMTAB
 cmdsize 24
  symoff 4216
   nsyms 0
  stroff 4392
 strsize 144
Load command 5
            cmd LC_DYSYMTAB
        cmdsize 80
      ilocalsym 0
      nlocalsym 8 (past the end of the symbol table)
     iextdefsym 8 (greater than the number of symbols)
     nextdefsym 2 (past the end of the symbol table)
      iundefsym 10 (greater than the number of symbols)
      nundefsym 1 (past the end of the symbol table)
...

And the native darwin tools generates an error for this file:

% nm macho-invalid-bad-symbol-index
nm: object: macho-invalid-bad-symbol-index truncated or malformed object (ilocalsym plus nlocalsym in LC_DYSYMTAB load command extends past the end of the symbol table)

I added new checks for the indexes and sizes for these in the
constructor of MachOObjectFile.  And added comments for what
would be a proper diagnostic messages.

And changed the test case using macho-invalid-bad-symbol-index
to test for the new error now produced.

Also added a test with a valid Mach-O file with a symbol table
load command where the number of symbols is zero that shows
the report_fatal_error() is not called.

llvm-svn: 258576
2016-01-22 22:49:55 +00:00
..
AArch64 [ELFYAML] Provide default value 0 for YAML relocation addendum field 2015-01-29 06:56:24 +00:00
AMDGPU ELFYAML: Add support for parsing AMDGPU section attribute flags 2015-11-13 17:06:29 +00:00
ARM llvm-nm: Don't print mapping symbols. 2015-06-25 21:00:51 +00:00
Inputs Fix the code that leads to the incorrect trigger of the report_fatal_error() 2016-01-22 22:49:55 +00:00
Mips [ELF] Explicitly configure sections alignment in the tests. NFC 2015-07-09 18:22:55 +00:00
X86 [opaque pointer type] Add textual IR support for explicit type parameter for global aliases 2015-09-11 03:22:04 +00:00
ar-create.test
ar-error.test
archive-delete.test lit: Add 'cd' support to the internal shell and port some tests 2015-03-02 21:33:18 +00:00
archive-error-tmp.txt
archive-extract-dir.test lit: Add 'cd' support to the internal shell and port some tests 2015-03-02 21:33:18 +00:00
archive-extract.test Accept lower case to handle windows error messages. 2015-07-14 22:42:21 +00:00
archive-format.test Trying to fix the windows bots. 2015-07-16 00:38:34 +00:00
archive-long-index.test
archive-move.test lit: Add 'cd' support to the internal shell and port some tests 2015-03-02 21:33:18 +00:00
archive-replace-pos.test
archive-symtab.test Tests: be slightly more specific to avoid conflict with path. 2015-10-26 13:40:03 +00:00
archive-toc.test Fix reading archive members with / in the name. 2015-07-13 23:07:05 +00:00
archive-update.test Stabilize llvm/test/Object/archive-update.test a bit. 2015-12-07 23:15:57 +00:00
check_binary_output.ll
coff-archive-short.test
coff-archive.test llvm-nm: treat weak undefined as undefined. 2015-07-06 21:36:23 +00:00
coff-invalid.test Check that COFF .obj files have sections with zero virtual address spaces. 2015-07-06 14:26:07 +00:00
corrupt.test Add dynamic_table iterators back to ELF.h. 2015-08-07 15:25:20 +00:00
directory.ll
dllimport-globalref.ll Object: Add XFAILed test case for r239560. 2015-06-24 18:03:39 +00:00
dllimport.ll Object: Prepend __imp_ when mangling a dllimport symbol in IRObjectFile. 2015-06-11 21:42:18 +00:00
dyn-rel-relocation.test [llvm-readobj][ELF] Teach llvm-readobj to show dynamic relocation in REL format 2016-01-16 22:40:09 +00:00
elf-reloc-no-sym.test
elf-unknown-type.test
invalid.test Report an error if a SHT_SYMTAB_SHNDX section has the wrong size. 2015-08-24 21:09:41 +00:00
kext.test Object: Test for reading kext bundles 2015-02-27 18:58:23 +00:00
lit.local.cfg Change how symbol sizes are handled in lib/Object. 2015-06-24 10:20:30 +00:00
macho-invalid.test Fix the code that leads to the incorrect trigger of the report_fatal_error() 2016-01-22 22:49:55 +00:00
mangle-ir.ll Revert "Change memcpy/memset/memmove to have dest and source alignments." 2015-11-19 05:56:52 +00:00
mri1.test
mri2.test
mri3.test
mri4.test
mri5.test
mri-addlib.test
mri-addmod.test
mri-crlf.test
nm-archive.test Identify thin archives as archives. 2015-07-22 18:29:39 +00:00
nm-darwin-m.test
nm-error.test
nm-irix6.test [Object] Support reading 64-bit MIPS ELF archives 2015-02-17 18:54:22 +00:00
nm-pe-image.test Update comments. 2015-08-06 20:05:27 +00:00
nm-shared-object.test
nm-trivial-object.test Fix llvm-nm -S option. 2015-05-22 13:28:35 +00:00
nm-universal-binary.test
nm-weak-global-macho.test
no-section-header-string-table.test [Object][ELF] Handle files with no section header string table. 2015-07-21 21:40:33 +00:00
no-section-table.test [llvm-readobj] Dump DT_RELACOUNT correctly. 2016-01-16 06:06:36 +00:00
obj2yaml-coff-long-file-symbol.test
obj2yaml-coff-long-section-name.test
obj2yaml-coff-section-aux-symbol.test
obj2yaml-coff-weak-external.test
obj2yaml-sectiongroup.test [obj2yaml/yaml2obj] Add SHT_GROUP support. 2015-02-21 04:28:26 +00:00
obj2yaml.test [llvm-readobj][ELF] Teach llvm-readobj to show arch specific ELF section's flags 2016-01-20 19:15:18 +00:00
objdump-export-list.test
objdump-file-header.test
objdump-no-sectionheaders.test
objdump-private-headers.test
objdump-reloc-shared.test
objdump-relocations.test
objdump-section-content.test
objdump-sectionheaders.test
objdump-shndx.test Add a test showing that objdump (and so ObjectFIle) can handle shndx. 2015-08-10 21:00:15 +00:00
objdump-symbol-table.test objdump: Don't print a (always 0) size for MachO symbols. 2015-06-23 15:45:38 +00:00
pr25877.test Handle archives with paths in the names. 2015-12-18 16:07:17 +00:00
readobj-absent.test Avoid SEGFAULT if a requested symbol section is absent. 2015-09-21 19:17:18 +00:00
readobj-elf-versioning.test
readobj-shared-object.test Fix printing of 64 bit values and make test more strict. 2015-10-01 17:57:31 +00:00
readobj.test
relocation-executable.test Support printing relocations in files with no section table. 2015-07-23 09:11:05 +00:00
simple-archive.test
size-trivial-macho.test
stackmap-dump.test [Stackmap] Pre-assemble the stackmap parser test case. (Fix builders). 2015-06-27 03:49:25 +00:00
yaml2obj-coff-multi-doc.test
yaml2obj-elf-alignment.yaml [yaml2obj] Align section content using AddressAlign field's value 2015-07-08 10:12:40 +00:00
yaml2obj-elf-bits-endian.test
yaml2obj-elf-file-headers-with-e_flags.yaml
yaml2obj-elf-file-headers.yaml
yaml2obj-elf-multi-doc.test
yaml2obj-elf-rel-noref.yaml [ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj tools 2015-07-03 23:00:54 +00:00
yaml2obj-elf-rel.yaml [yaml2obj] Use regex to match sections offsets. NFC 2015-07-08 06:57:24 +00:00
yaml2obj-elf-section-basic.yaml [yaml2obj] Initialize sh_addralign field for the .symtab section 2015-07-09 18:23:02 +00:00
yaml2obj-elf-section-invalid-size.yaml
yaml2obj-elf-symbol-basic.yaml [ELF] Explicitly configure sections alignment in the tests. NFC 2015-07-09 18:22:55 +00:00
yaml2obj-elf-symbol-LocalGlobalWeak.yaml
yaml2obj-elf-symbol-visibility.yaml
yaml2obj-readobj.test