llvm-project/llvm/test/tools
Kevin Enderby feb63b9391 Actually add error handling to unpacking the dyld compact bind and
other tables.  Providing a helpful error message to what the error is and
where the error occurred based on which opcode it was associated with.

There have been handful of bug fixes dealing with bad bind info in
object files, r294021 and r249845, which only put a band aid on the
problem after a bad bind table was created after unpacking from
its compact info.  In these cases a bind table should have never been
created and an error should have simply been generated.

This change puts in place the plumbing to allow checking and returning
of an error when the compact info is unpacked.  This follows the model
of iterators that can fail that Lang Hanes designed when fixing the problem
for bad archives r275316 (or r275361).

This change uses one of the existing test cases that now causes an
error instead of printing <<bad library ordinal>> after a bad bind table
is created.  The error uses the offset into the opcode table as shown with
the macOS dyldinfo(1) tool to indicate where the error is and which
opcode and which parameter is in error.

For example the exiting test case has this lazy binding opcode table:

% dyldinfo -opcodes test/tools/llvm-objdump/Inputs/bad-ordinal.macho-x86_64 
…
lazy binding opcodes:
0x0000 BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(0x02, 0x00000010)
0x0002 BIND_OPCODE_SET_DYLIB_ORDINAL_IMM(2)

In the test case the binary only has one library so setting the library 
ordinal to the value of 2 in the BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
opcode at 0x0002 above is an error.  This now produces this error message:

% llvm-objdump -lazy-bind bad-ordinal.macho-x86_64 
…
llvm-objdump: 'bad-ordinal.macho-x86_64': truncated or malformed object (for BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB bad library ordinal: 2 (max 1) for opcode at: 0x2)

This change provides the plumbing for the error handling and one example
of an error message.  Other error checks and test cases will be added in follow
on commits.

llvm-svn: 296527
2017-02-28 21:47:07 +00:00
..
dsymutil [dsymutil] Fix handling of empty CUs in LTO links. 2017-02-09 19:41:55 +00:00
gold [ThinLTO] PrintStatistics when we exit early for thinlto-index-only 2017-02-02 17:33:53 +00:00
llvm-ar
llvm-config [llvm-config] Canonicalize CMake booleans to 0/1 2017-01-10 19:55:51 +00:00
llvm-cov [llvm-cov] Error-out when an unsupported format is used (PR32087) 2017-02-28 16:57:28 +00:00
llvm-cxxdump
llvm-cxxfilt llvm-cxxfilt: support `-_` 2017-01-22 17:41:10 +00:00
llvm-dwp [llvm-dwp] - Reuse object::Decompressor class 2017-01-13 15:58:55 +00:00
llvm-lit
llvm-lto [LTO] Reject modules without datalayout. 2016-12-14 21:57:04 +00:00
llvm-lto2 Temporarily revert "For X86-64 linux and PPC64 linux align int128 to 16 bytes." 2017-02-10 04:35:32 +00:00
llvm-mc
llvm-modextract
llvm-nm Change the test added in r293099 so it does not have the string "llvm-nm" to fix 2017-01-25 23:57:32 +00:00
llvm-objdump Actually add error handling to unpacking the dyld compact bind and 2017-02-28 21:47:07 +00:00
llvm-opt-report [llvm-opt-report] Fix context-sensitive lines where nothing happened 2017-01-07 20:21:17 +00:00
llvm-pdbdump
llvm-profdata
llvm-readobj [WebAssembly] Update llvm-readobj tests for switch to version 0x1 2017-02-22 21:01:17 +00:00
llvm-size
llvm-split
llvm-strings llvm-strings: add support for `-t` 2017-01-21 02:36:28 +00:00
llvm-symbolizer Get function start line number from DWARF info 2017-02-06 20:19:02 +00:00
llvm-xray/X86 [XRAY] A Color Choosing helper for XRay Graph 2017-02-25 00:26:42 +00:00
lto Fix test/tools/lto/hide-linkonce-odr.ll after r289719 2016-12-15 01:31:38 +00:00
sancov [sancov] applying blacklist to covered points too 2017-01-19 03:49:18 +00:00
sanstats
yaml2obj