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
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to