1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
llvm-mirror/lib/Object
Kevin Enderby 3bd0231fd8 Start to add real error messages for malformed Mach-O files.
And update the existing test cases in test/Object/macho-invalid.test
to use llvm-objdump with the -macho option to produce these
error messages and stop producing the generic "Invalid data
was encountered while parsing the file" message.

Working from the beginning of the file, if the mach header is too large for
the size of the file and then if the load commands that follow extend past
the end of the file these two errors now generate correct error messages.

Both of these have existing test cases in test/Object/macho-invalid.test .

But the first with macho-invalid-header it will never trigger the error message
"mach header extends past the end of the file" using any of the llvm tools as
they all use identify_magic() which rejects files with the correct magic number
that are too small in size.  So I tested this by hacking that code and seeing the
error message down in parseHeader() really does happen.  So in case there
is ever code in llvm that directly calls createMachOObjectFile() this error
message will be correctly produced.

The second error message of "load commands extends past the end of the file"
is triggered by a number of existing tests cases in test/Object/macho-invalid.test .
Also other tests trigger different error messages now like "ilocalsym plus
nlocalsym in LC_DYSYMTAB load command extends past the end of the
symbol table".

There are two existing test cases that still get the "Invalid data was encountered ..."
error messages that I will tackle next.  But they will involve a bit of pluming an
Expect<...> up through the call stack and I want to do those as separate changes.

FYI, for those test cases that were trying to test specific errors that now get
different errors I’ll fix those in follow on changes and create new test cases
for those so they test the error they were meant to test.

llvm-svn: 266248
2016-04-13 21:17:58 +00:00
..
Archive.cpp Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message 2016-04-06 22:14:09 +00:00
ArchiveWriter.cpp Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message 2016-04-06 22:14:09 +00:00
Binary.cpp Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message 2016-04-06 22:14:09 +00:00
CMakeLists.txt [ThinLTO] Renaming of function index to module summary index (NFC) 2016-03-15 00:04:37 +00:00
COFFObjectFile.cpp Fix a crash in running llvm-objdump -t with an invalid Mach-O file already 2016-03-23 20:27:00 +00:00
ELF.cpp [lanai] Add ELF enum value and relocations. 2016-03-01 21:21:42 +00:00
ELFObjectFile.cpp [Object, ELF] Don't assert on invalid magic in createELFObjectFile. 2015-06-04 23:14:43 +00:00
Error.cpp [Object] Start threading Error through MachOObjectFile construction. 2016-03-25 17:25:34 +00:00
IRObjectFile.cpp Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message 2016-04-06 22:14:09 +00:00
LLVMBuild.txt
MachOObjectFile.cpp Start to add real error messages for malformed Mach-O files. 2016-04-13 21:17:58 +00:00
MachOUniversal.cpp [Object] Make createMachOObjectFile return Expected<...> rather than 2016-03-25 23:11:52 +00:00
ModuleSummaryIndexObjectFile.cpp Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message 2016-04-06 22:14:09 +00:00
Object.cpp Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message 2016-04-06 22:14:09 +00:00
ObjectFile.cpp Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message 2016-04-06 22:14:09 +00:00
RecordStreamer.cpp Move alignment from MCSectionData to MCSection. 2015-05-21 19:20:38 +00:00
RecordStreamer.h Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
SymbolicFile.cpp Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump to produce a real error message 2016-04-06 22:14:09 +00:00
SymbolSize.cpp [SymbolSize] Skip sorting by index, just assign by index. 2015-06-29 16:05:00 +00:00