The --load option should work if all of the program headers have the right 
addresses. LLDB should try to load all PT_LOAD program headers into memory at 
the address that they are loaded at.

Is this a baseboard situation where you have an ELF file that has program 
headers with all of the correct load addresses? If so, you want to make sure 
that you specify no OS and no vendor when loading your target:

(lldb) target create --arch armv7-none-none

Why? Because when LLDB knows where is no OS and no vendor then it will select 
the right dynamic loader plug-in. This plug-in will automatically set the 
"load" address for all program headers to match the "file" address found in the 
ELF file. If LLDB believes you have an OS that you are running on, it will try 
and load a dynamic loader plugin that will wait until that plugin detects that 
your executable has been dynamically loaded and try to set the "load" address 
intelligently.

LLDB has the notion of "load" and "file" addresses. "file" addresses are 
addresses as they are found in each executable or shared library object file 
(ELF, mach-o, COFF, etc) that exists in your target. Once your program is 
running, the dynamic loader will try and determine the "load" address for each 
section within each executable using the dynamic loader plug-in. Dynamic loader 
plug-ins are loaded based off of the target triple in your target.

If your ELF file has the entry point correctly set, you can use the 
"--set-pc-to-entry" option.

So if you have a static ELF file where all addresses are correct, you can 
probably use:

(lldb) target create --arch armv7-none-none a.out
(lldb) target modules load --file a.out --load --set-pc-to-entry

You can also set your load addresses manually using this command by specifying 
the any number of section name + section address tuples:

(lldb) target create --arch armv7-none-none a.out
(lldb) target modules load --file a.out --load --set-pc-to-entry .text 0x200000 
.data 0x300000



> On Jul 22, 2020, at 9:10 AM, via lldb-dev <lldb-dev@lists.llvm.org> wrote:
> 
> Hello,
> we are trying to debug firmware running on a stm32 using OpenOCD and LLDB.
> GNU-GDB provides a ‘load’ command to load the sections from an ELF file to 
> the target device.
> We have tried to use ‘target modules load --load’ command to load ELF 
> sections to a specific address, but that didn’t work.
> If there is a way at all, what is the proper way to load the executable to 
> the target device with LLDB?
> _______________________________________________
> lldb-dev mailing list
> lldb-dev@lists.llvm.org <mailto:lldb-dev@lists.llvm.org>
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev 
> <https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev>
_______________________________________________
lldb-dev mailing list
lldb-dev@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

Reply via email to