1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
llvm-mirror/tools/llvm-readobj
Georgii Rymar 04b897752e Recommit: [llvm-readelf/obj] - Allow dumping of ELF header even if some elements are corrupt.
This is recommit for D90903 with fixes for BB:
1) Used std::move<> when returning Expected<> (http://lab.llvm.org:8011/#/builders/112/builds/913)
2) Fixed the name of temporarily file in the file-headers.test (http://lab.llvm.org:8011/#/builders/36/builds/1269)
   (a local old temporarily file was used before)

For creating `ELFObjectFile` instances we have the factory method
`ELFObjectFile<ELFT>::create(MemoryBufferRef Object)`.

The problem of this method is that it scans the section header to locate some sections.
When a file is truncated or has broken fields in the ELF header, this approach does
not allow us to create the `ELFObjectFile` and dump the ELF header.

This is https://bugs.llvm.org/show_bug.cgi?id=40804

This patch suggests a solution - it allows to delay scaning sections in the
`ELFObjectFile<ELFT>::create`. It now allows user code to call an object
initialization (`initContent()`) later. With that it is possible,
for example, for dumpers just to dump the file header and exit.
By default initialization is still performed as before, what helps to keep
the logic of existent callers untouched.

I've experimented with different approaches when worked on this patch.
I think this approach is better than doing initialization of sections (i.e. scan of them)
on demand, because normally users of `ELFObjectFile` API expect to work with a valid object.
In most cases when a section header table can't be read (because of an error), we don't
have to continue to work with object. So we probably don't need to implement a more complex API.

Differential revision: https://reviews.llvm.org/D90903
2020-11-09 12:53:53 +03:00
..
ARMEHABIPrinter.h [llvm-readobj][ARM] - Improve support of printing unwind (-u) information for non-relocatable objects. 2020-09-30 11:43:34 +03:00
ARMWinEHPrinter.cpp [llvm-readobj] [ARMWinEH] Print ARM64 packed unwind info 2020-09-15 08:50:02 +03:00
ARMWinEHPrinter.h [llvm-readobj] [ARMWinEH] Print ARM64 packed unwind info 2020-09-15 08:50:02 +03:00
CMakeLists.txt [llvm-readobj] - Remove Error.cpp,.h and drop dependencies in the code. 2020-09-01 16:46:17 +03:00
COFFDumper.cpp Reland [CFGuard] Add address-taken IAT tables and delay-load support 2020-10-13 13:20:52 -07:00
COFFImportDumper.cpp
DwarfCFIEHPrinter.h llvm-dwarfdump: Support verbose printing DW_OP_convert to print the CU local offset before the resolved absolute offset 2020-10-23 18:50:15 -07:00
ELFDumper.cpp Recommit: [llvm-readelf/obj] - Allow dumping of ELF header even if some elements are corrupt. 2020-11-09 12:53:53 +03:00
llvm-readobj.cpp Recommit: [llvm-readelf/obj] - Allow dumping of ELF header even if some elements are corrupt. 2020-11-09 12:53:53 +03:00
llvm-readobj.h
LLVMBuild.txt
MachODumper.cpp [llvm-readobj] Don't print out section names for STABS symbols 2020-10-12 18:55:40 -07:00
ObjDumper.cpp [llvm-readelf/obj] - Cleanup the code. NFCI. 2020-09-23 12:58:22 +03:00
ObjDumper.h Recommit: [llvm-readelf/obj] - Allow dumping of ELF header even if some elements are corrupt. 2020-11-09 12:53:53 +03:00
StackMapPrinter.h
WasmDumper.cpp [llvm-readobj] - Remove Error.cpp,.h and drop dependencies in the code. 2020-09-01 16:46:17 +03:00
Win64EHDumper.cpp [llvm-readobj] - Remove Error.cpp,.h and drop dependencies in the code. 2020-09-01 16:46:17 +03:00
Win64EHDumper.h
WindowsResourceDumper.cpp [llvm-readobj] - Remove Error.cpp,.h and drop dependencies in the code. 2020-09-01 16:46:17 +03:00
WindowsResourceDumper.h
XCOFFDumper.cpp [llvm-readobj] - Remove Error.cpp,.h and drop dependencies in the code. 2020-09-01 16:46:17 +03:00