1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00
llvm-mirror/test
Kevin Enderby 1a15e5c9c5 Fix a crash in running llvm-objdump -t with an invalid Mach-O file already
in the test suite. While this is not really an interesting tool and option to run
on a Mach-O file to show the symbol table in a generic libObject format
it shouldn’t crash.

The reason for the crash was in MachOObjectFile::getSymbolType() when it was
calling MachOObjectFile::getSymbolSection() without checking its return value
for the error case.

What makes this fix require a fair bit of diffs is that the method getSymbolType() is
in the class ObjectFile defined without an ErrorOr<> so I needed to add that all
the sub classes.  And all of the uses needed to be updated and the return value
needed to be checked for the error case.

The MachOObjectFile version of getSymbolType() “can” get an error in trying to
come up with the libObject’s internal SymbolRef::Type when the Mach-O symbol
symbol type is an N_SECT type because the code is trying to select from the
SymbolRef::ST_Data or SymbolRef::ST_Function values for the SymbolRef::Type.
And it needs the Mach-O section to use isData() and isBSS to determine if
it will return SymbolRef::ST_Data.

One other possible fix I considered is to simply return SymbolRef::ST_Other
when MachOObjectFile::getSymbolSection() returned an error.  But since in
the past when I did such changes that “ate an error in the libObject code” I
was asked instead to push the error out of the libObject code I chose not
to implement the fix this way.

As currently written both the COFF and ELF versions of getSymbolType()
can’t get an error.  But if isReservedSectionNumber() wanted to check for
the two known negative values rather than allowing all negative values or
the code wanted to add the same check as in getSymbolAddress() to use
getSection() and check for the error then these versions of getSymbolType()
could return errors.

At the end of the day the error printed now is the generic “Invalid data was
encountered while parsing the file” for object_error::parse_failed.  In the
future when we thread Lang’s new TypedError for recoverable error handling
though libObject this will improve.  And where the added // Diagnostic(…
comment is, it would be changed to produce and error message
like “bad section index (42) for symbol at index 8” for this case.

llvm-svn: 264187
2016-03-23 20:27:00 +00:00
..
Analysis Revert "Support arbitrary addrspace pointers in masked load/store intrinsics" 2016-03-22 20:24:34 +00:00
Assembler Revert "Support arbitrary addrspace pointers in masked load/store intrinsics" 2016-03-22 20:24:34 +00:00
Bindings Expose IRBuilder::CreateAtomicCmpXchg as LLVMBuildAtomicCmpXchg in the C API. 2016-03-19 21:28:28 +00:00
Bitcode Upgrade TBAA *before* upgrading intrinsics 2016-03-16 23:17:54 +00:00
BugPoint
CodeGen Codegen: [PPC] Word Rotates are Zero Extending. 2016-03-23 19:51:22 +00:00
DebugInfo Remove leftover options from multiline.ll 2016-03-21 21:25:01 +00:00
Examples
ExecutionEngine
Feature [NVVM] Remove noduplicate attribute from synchronizing intrinsics. 2016-03-22 22:08:01 +00:00
FileCheck
Instrumentation [msan] Don't put module constructors in comdats. 2016-03-15 20:25:47 +00:00
Integer
JitListener
LibDriver
Linker Drop comdats from the dst module if they are not selected. 2016-03-22 21:35:47 +00:00
LTO
MC [AArch64] Replace some uses of report_fatal_error with reportError in AArch64 ELF object writer 2016-03-23 13:45:03 +00:00
Object Fix a crash in running llvm-objdump -t with an invalid Mach-O file already 2016-03-23 20:27:00 +00:00
Other [CG] Add a new pass manager printer pass for the old call graph and 2016-03-10 11:24:11 +00:00
SymbolRewriter
TableGen [GlobalISel][Target] Add an opcode for unconditional branch. 2016-03-11 17:27:38 +00:00
ThinLTO/X86 [ThinLTO] Renaming of function index to module summary index (NFC) 2016-03-15 00:04:37 +00:00
tools Revert "[llvm-objdump] Printing relocations in executable and shared object files. This partially reverts r215844 by removing test objdump-reloc-shared.test which stated GNU objdump doesn't print relocations, it does." 2016-03-21 20:59:15 +00:00
Transforms Fix bugs in the MemorySSA walker. 2016-03-23 18:31:55 +00:00
Unit [lit] Hack lit to allow a test suite to request that it is run "early". 2016-03-12 03:03:31 +00:00
Verifier Introduce @llvm.experimental.deoptimize 2016-03-11 19:08:34 +00:00
YAMLParser
.clang-format
CMakeLists.txt
lit.cfg [lit] Teach lit about global-isel requirement. 2016-03-08 00:03:40 +00:00
lit.site.cfg.in
TestRunner.sh