[Lldb-commits] [lldb] [lldb] Fix address to read segment data (PR #120655)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Fri Dec 20 03:59:21 PST 2024
https://github.com/labath commented:
I'm pretty sure this is not correct. `p_offset` is an offset in the file. It tells you nothing about how the file is mapped into memory.
What you're *probably* running into is an executable whose base address (`p_vaddr` of the first `PT_LOAD` segment) is not zero. This is true for all non-PIE executables, but it can be true for other kinds of files as well.
Since the value you get for `address` here is the actual address of the first load segment (rather than the *delta* between the virtual and actual addresses, which is used in some other places), what you need to do here is to subtract the address of the first segment from the result. This way you get zero for the first segment, and then a delta for all the others. Take a look at [this](https://github.com/llvm/llvm-project/blob/d7ddc976d544528fe7f16882f5bec66c3b2a7884/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp#L64) code doing something similar.
https://github.com/llvm/llvm-project/pull/120655
More information about the lldb-commits
mailing list