mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
9b924af8f7
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 |
||
---|---|---|
.. | ||
AArch64 | ||
AMDGPU | ||
ARM | ||
Inputs | ||
Mips | ||
X86 | ||
ar-create.test | ||
ar-error.test | ||
archive-delete.test | ||
archive-error-tmp.txt | ||
archive-extract-dir.test | ||
archive-extract.test | ||
archive-format.test | ||
archive-long-index.test | ||
archive-move.test | ||
archive-replace-pos.test | ||
archive-symtab.test | ||
archive-toc.test | ||
archive-update.test | ||
check_binary_output.ll | ||
coff-archive-short.test | ||
coff-archive.test | ||
coff-invalid.test | ||
corrupt.test | ||
directory.ll | ||
dllimport-globalref.ll | ||
dllimport.ll | ||
dyn-rel-relocation.test | ||
elf-reloc-no-sym.test | ||
elf-unknown-type.test | ||
invalid.test | ||
kext.test | ||
lit.local.cfg | ||
macho-invalid.test | ||
mangle-ir.ll | ||
mri1.test | ||
mri2.test | ||
mri3.test | ||
mri4.test | ||
mri5.test | ||
mri-addlib.test | ||
mri-addmod.test | ||
mri-crlf.test | ||
nm-archive.test | ||
nm-darwin-m.test | ||
nm-error.test | ||
nm-irix6.test | ||
nm-pe-image.test | ||
nm-shared-object.test | ||
nm-trivial-object.test | ||
nm-universal-binary.test | ||
nm-weak-global-macho.test | ||
no-section-header-string-table.test | ||
no-section-table.test | ||
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.test | ||
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 | ||
objdump-symbol-table.test | ||
pr25877.test | ||
readobj-absent.test | ||
readobj-elf-versioning.test | ||
readobj-shared-object.test | ||
readobj.test | ||
relocation-executable.test | ||
simple-archive.test | ||
size-trivial-macho.test | ||
stackmap-dump.test | ||
yaml2obj-coff-multi-doc.test | ||
yaml2obj-elf-alignment.yaml | ||
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 | ||
yaml2obj-elf-rel.yaml | ||
yaml2obj-elf-section-basic.yaml | ||
yaml2obj-elf-section-invalid-size.yaml | ||
yaml2obj-elf-symbol-basic.yaml | ||
yaml2obj-elf-symbol-LocalGlobalWeak.yaml | ||
yaml2obj-elf-symbol-visibility.yaml | ||
yaml2obj-readobj.test |