1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00
llvm-mirror/lib/Object
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
..
Archive.cpp
ArchiveWriter.cpp [llvm-ar][Object] Fix detection of need for 64-bit archive symbol tables 2020-10-26 12:29:28 +00:00
Binary.cpp Recommit: [llvm-readelf/obj] - Allow dumping of ELF header even if some elements are corrupt. 2020-11-09 12:53:53 +03:00
CMakeLists.txt
COFFImportFile.cpp
COFFModuleDefinition.cpp
COFFObjectFile.cpp Fix various format specifier mismatches 2020-10-18 12:39:15 -04:00
Decompressor.cpp
ELF.cpp Introduce and use a new section type for the bb_addr_map section. 2020-10-08 11:13:19 -07:00
ELFObjectFile.cpp Recommit: [llvm-readelf/obj] - Allow dumping of ELF header even if some elements are corrupt. 2020-11-09 12:53:53 +03:00
Error.cpp
IRObjectFile.cpp
IRSymtab.cpp
LLVMBuild.txt
MachOObjectFile.cpp [MachO] Also recongize __swift_ast as a debug info section 2020-11-02 14:49:57 -08:00
MachOUniversal.cpp
MachOUniversalWriter.cpp [llvm-objcopy][MachO] Add support for universal binaries 2020-10-06 04:01:40 -07:00
Minidump.cpp
ModuleSymbolTable.cpp
Object.cpp
ObjectFile.cpp Recommit: [llvm-readelf/obj] - Allow dumping of ELF header even if some elements are corrupt. 2020-11-09 12:53:53 +03:00
RecordStreamer.cpp [MC] Make MCStreamer aware of AsmParser's StartTokLoc 2020-11-02 12:32:07 -08:00
RecordStreamer.h [MC] Make MCStreamer aware of AsmParser's StartTokLoc 2020-11-02 12:32:07 -08:00
RelocationResolver.cpp [WebAssembly] Implementation of (most) table instructions 2020-10-23 08:42:54 -07:00
SymbolicFile.cpp Recommit: [llvm-readelf/obj] - Allow dumping of ELF header even if some elements are corrupt. 2020-11-09 12:53:53 +03:00
SymbolSize.cpp
TapiFile.cpp
TapiUniversal.cpp
WasmObjectFile.cpp [WebAssembly] Implementation of (most) table instructions 2020-10-23 08:42:54 -07:00
WindowsMachineFlag.cpp
WindowsResource.cpp
XCOFFObjectFile.cpp