1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
llvm-mirror/lib
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
..
Analysis [opaque pointer types] [NFC] DataLayout::getIndexedOffset: take source element type instead of pointer type and rename to getIndexedOffsetInType. 2016-01-22 03:08:27 +00:00
AsmParser Implemented Support of IA interrupt and exception handlers: 2015-12-21 14:07:14 +00:00
Bitcode [ThinLTO] Avoid unnecesary hash lookups during metadata linking (NFC) 2016-01-21 16:46:40 +00:00
CodeGen Fix LivePhysRegs::addLiveOuts 2016-01-22 22:21:34 +00:00
DebugInfo Fix instance of -Wcovered-switch-default 2016-01-13 20:39:22 +00:00
ExecutionEngine [RuntimeDyld][AArch64] Add support for the MachO ARM64_RELOC_SUBTRACTOR reloc. 2016-01-21 21:59:50 +00:00
Fuzzer Use std::piecewise_constant_distribution instead of ad-hoc binary search. 2016-01-22 22:28:27 +00:00
IR Replace Type::getInt32Ty() and comparison by isIntegerTy(32). NFC. 2016-01-22 03:30:27 +00:00
IRReader [ThinLTO] Metadata linking for imported functions 2015-12-17 17:14:09 +00:00
LibDriver [Option] Use an ArrayRef to store the Option Infos in OptTable. NFC 2015-10-21 16:30:42 +00:00
LineEditor
Linker [ThinLTO] Do metadata linking during batch function importing 2016-01-22 00:15:53 +00:00
LTO [LTO] Fix error reporting when a file passed to libLTO is invalid or non-existent 2016-01-20 09:03:42 +00:00
MC Rename MCLineEntry to MCDwarfLineEntry 2016-01-21 01:59:03 +00:00
Object Fix the code that leads to the incorrect trigger of the report_fatal_error() 2016-01-22 22:49:55 +00:00
Option Convert Arg, ArgList, and Option to dump() to dbgs() rather than errs(). 2015-12-18 18:55:26 +00:00
Passes [attrs] Extract the pure inference of function attributes into 2015-12-27 08:41:34 +00:00
ProfileData [PGO] Remove use of static variable. /NFC 2016-01-22 20:25:56 +00:00
Support AMDGPU: Fix getArchTypePrefix 2016-01-22 19:09:12 +00:00
TableGen [TableGen] Use FoldingSets instead of DenseMaps to unique UnOpInit, BinOpInit and TernOpInit. This remove the memory needed to store the key for the DenseMap. NFC 2016-01-18 20:36:06 +00:00
Target fix typos; NFC 2016-01-22 22:09:41 +00:00
Transforms AMDGPU: Rename intrinsics to use amdgcn prefix 2016-01-22 21:30:34 +00:00
CMakeLists.txt
LLVMBuild.txt
Makefile