[lldb-dev] How to load core on a different machine? - image base addresses

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Thu Jan 7 09:54:42 PST 2016


> On Jan 7, 2016, at 9:48 AM, Eugene Birukov <eugenebi at hotmail.com> wrote:
> 
> > It is now!
> 
> Good :). Any plans to fix it? I guess I should just file a bug, right?
> 

Please file a bug. Someone probably will from the linux community, possibly even you?

> > The main question is what do you consider to be your "image address"?
> 
> I need the address that I feed to SBTarget::SetModuleLoadAddress() if I load modules manually.
> 
> I iterated over module sections. As I understand, the base address  is 0x7fc7125ff000. I verified it by really calling SetModuleLoadAddress() and looking at stacks that LLDB produces. But to find it programmatically I'll need to do some math: pick any section with non-zero size and subtract its file address form its memory address. Hmm... seems like a workaround, but it would be better to have a more direct way.
> 
> (x86_64) /home/eugene/joe/so/libjemalloc.so.1
> 0xffffffffffffffff [0x0000000000000000-0x0000000000000000) libjemalloc.so.1.
> 0x7fc7125ff200 [0x0000000000000200-0x0000000000000224) libjemalloc.so.1..note.gnu.build-id
> 0x7fc7125ff228 [0x0000000000000228-0x0000000000000328) libjemalloc.so.1..gnu.hash
> 0x7fc7125ff328 [0x0000000000000328-0x0000000000000b08) libjemalloc.so.1..dynsym
> 0x7fc7125ffb08 [0x0000000000000b08-0x0000000000000f01) libjemalloc.so.1..dynstr
> 0x7fc7125fff02 [0x0000000000000f02-0x0000000000000faa) libjemalloc.so.1..gnu.version
> 0x7fc7125fffb0 [0x0000000000000fb0-0x0000000000001040) libjemalloc.so.1..gnu.version_r
> 0x7fc712600040 [0x0000000000001040-0x0000000000002c00) libjemalloc.so.1..rela.dyn
> 0x7fc712601c00 [0x0000000000002c00-0x0000000000003008) libjemalloc.so.1..rela.plt
> 0x7fc712602008 [0x0000000000003008-0x0000000000003022) libjemalloc.so.1..init
> 0x7fc712602030 [0x0000000000003030-0x00000000000032f0) libjemalloc.so.1..plt
> 0x7fc7126022f0 [0x00000000000032f0-0x00000000000286fa) libjemalloc.so.1..text
> 0x7fc7126276fc [0x00000000000286fc-0x0000000000028705) libjemalloc.so.1..fini
> 0x7fc712627740 [0x0000000000028740-0x000000000002a344) libjemalloc.so.1..rodata
> 0x7fc712629344 [0x000000000002a344-0x000000000002afa0) libjemalloc.so.1..eh_frame_hdr
> 0x7fc712629fa0 [0x000000000002afa0-0x000000000002fdcc) libjemalloc.so.1..eh_frame
> 0x7fc71282f710 [0x0000000000230710-0x0000000000230714) libjemalloc.so.1..tdata
> 0x7fc71282f718 [0x0000000000230718-0x0000000000230748) libjemalloc.so.1..tbss
> 0x7fc71282f718 [0x0000000000230718-0x0000000000230728) libjemalloc.so.1..init_array
> 0x7fc71282f728 [0x0000000000230728-0x0000000000230730) libjemalloc.so.1..fini_array
> 0x7fc71282f730 [0x0000000000230730-0x0000000000230738) libjemalloc.so.1..jcr
> 0x7fc71282f740 [0x0000000000230740-0x0000000000231d70) libjemalloc.so.1..data.rel.ro
> 0x7fc712830d70 [0x0000000000231d70-0x0000000000231f70) libjemalloc.so.1..dynamic
> 0x7fc712830f70 [0x0000000000231f70-0x0000000000232000) libjemalloc.so.1..got
> 0x7fc712831000 [0x0000000000232000-0x0000000000232170) libjemalloc.so.1..got.plt
> 0x7fc712831180 [0x0000000000232180-0x0000000000232209) libjemalloc.so.1..data
> 0x7fc712831220 [0x0000000000232220-0x00000000002334b0) libjemalloc.so.1..bss
> 0xffffffffffffffff [0x0000000000000000-0x0000000000000000) libjemalloc.so.1..gnu_debuglink
> 0xffffffffffffffff [0x0000000000000000-0x0000000000000000) libjemalloc.so.1..shstrtab

So try the following:

(lldb) memory read 0x7fc7125ff000

See if you see the "ELF\x7d" magic byte string. If so, then this is definitely the address you are looking for. You can also set a breakpoint when the shared libraries get loaded and see where the image is being loaded since I believe the POSIX Dynamic Loader loads things using a single address that it gets from somewhere. This address that is used by the dynamic loader should be the address that is displayed...

Greg


More information about the lldb-dev mailing list