[Question] Is there a way to specify an offset to the loaded symbols?

Christian Biesinger cbiesinger@google.com
Thu Oct 29 12:29:51 GMT 2020


On Thu, Oct 29, 2020 at 9:23 AM Marten Ringwelski <git@maringuu.de> wrote:
>
> Hello,
> for some reason that is not important here I need to debug a binary that is executed by calling the linker manually.
> In my case I do `/lib/ld-musl-x86_64.so.1 binary`.
> The problem with this is that gdb now obviously thinks that I want to debug `/lib/ld-musl-x86_64.so.1`. This is not the case.
> Loading the symbols from `binary` does not help since the the linker loads the process into memory and the jumps to its main.
>
> In other words I have the symbols for the binary to be debugged but the binary is loaded into memory with an offset so the symbols are offseted.
> Is there any way to get this working?

add-symbol-file lets you specify an address but maybe it's easier if
you just use patchelf --set-interpreter to make it use
/lib/ld-musl-x86_64.so.1

Christian


More information about the Gdb mailing list