hanchenye-llvm-project/lldb/lit
Pavel Labath 7db8b5c4bd ObjectFilePECOFF: Create a "container" section spanning the entire module image
Summary:
This is coming from the discussion in D55356 (the most interesting part
happened on the mailing list, so it isn't reflected on the review page).

In short the issue is that lldb assumes that all bytes of a module image
in memory will be backed by a "section". This isn't the case for PECOFF
files because the initial bytes of the module image will contain the
file header, which does not correspond to any normal section in the
file. In particular, this means it is not possible to implement
GetBaseAddress function for PECOFF files, because that's supposed point
to the first byte of that header.

If my (limited) understanding of how PECOFF files work is correct, then
the OS is expecded to load the entire module into one continuous chunk
of memory. The address of that chunk (+/- ASLR) is given by the "image
base" field in the COFF header, and it's size by "image size". All of
the COFF sections are then loaded into this range.

If that's true, then we can model this behavior in lldb by creating a
"container" section to represent the entire module image, and then place
other sections inside that. This would make be consistent with how MachO
and ELF files are modelled (except that those can have multiple
top-level containers as they can be loaded into multiple discontinuous
chunks of memory).

This change required a small number of fixups in the PDB plugins, which
assumed a certain order of sections within the object file (which
obivously changes now). I fix this by changing the lookup code to use
section IDs (which are unchanged) instead of indexes. This has the nice
benefit of removing spurious -1s in the plugins as the section IDs in
the pdbs match the 1-based section IDs in the COFF plugin.

Besides making the implementation of GetBaseAddress possible, this also
improves the lookup of addresses in the gaps between the object file
sections, which will now be correctly resolved as belonging to the
object file.

Reviewers: zturner, amccarth, stella.stamenova, clayborg, lemo

Reviewed By: clayborg, lemo

Subscribers: JDevlieghere, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D56537

llvm-svn: 353916
2019-02-13 07:17:24 +00:00
..
Breakpoint build.py: Implement "gcc" builder 2018-12-12 08:54:14 +00:00
BuildScript build.py: Implement "gcc" builder 2018-12-12 08:54:14 +00:00
Commands [testsuite] Convert a pexpect test to lit. 2019-02-06 21:48:01 +00:00
Driver [testsuite] Add a comment explaining what this test does. 2019-02-12 23:02:53 +00:00
ExecControl/StopHook [Test] Fix up tests affected by the new LLVM header. 2019-01-22 03:50:44 +00:00
Expr [lit] Make sure tests are actually skipped on darwin and windows. 2019-01-17 21:57:33 +00:00
Heap Fix lldb's macosx/heap.py cstr command. 2018-12-17 18:21:51 +00:00
Minidump Revert "minidump: Add ability to attach (breakpad) symbol files to placeholder modules" 2019-02-11 10:30:24 +00:00
Modules ObjectFilePECOFF: Create a "container" section spanning the entire module image 2019-02-13 07:17:24 +00:00
Python Fix REQUIRES line 2018-12-18 20:28:54 +00:00
Quit [lldb] Update shebang python2 -> python 2019-01-26 01:05:02 +00:00
Reproducer [Reproducers] Integrate FileProvider with clang 2019-02-13 01:30:41 +00:00
Settings Refactor the lit configuration files 2018-11-02 17:49:01 +00:00
Suite [lit] Fix lldbtest format 2019-01-17 23:30:06 +00:00
SymbolFile [NativePDB] Process virtual bases in the correct order 2019-02-12 08:17:11 +00:00
Unit [CMake] In standalone builds, LLVM_BINARY_DIR should point to LLVM's binary directory 2019-01-09 16:25:37 +00:00
helper [build.py] Add `-fms-compatibility-version=19` to `build.py` 2019-02-11 15:13:33 +00:00
tools/lldb-mi [lldb] [test] Skip lldb-mi test if LLDB_DISABLE_PYTHON is used 2019-02-11 14:09:43 +00:00
CMakeLists.txt [CMake] Quick-Fix targets don't exist when building against LLVM install-tree with LLDB_INCLUDE_TESTS=ON 2019-01-28 16:15:27 +00:00
lit-lldb-init Add EchoCommentCommands to CommandInterpreterRunOptions in addition to the existing EchoCommands and expose both as interpreter settings. 2018-10-05 16:49:47 +00:00
lit.cfg.py Fix clang test suite on Windows by reverting part of r347216 2018-11-19 19:36:28 +00:00
lit.site.cfg.py.in [lldb] [test] Skip lldb-mi test if LLDB_DISABLE_PYTHON is used 2019-02-11 14:09:43 +00:00