public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* [Question] Is there a way to specify an offset to the loaded symbols?
@ 2020-10-29  8:13 Marten Ringwelski
  2020-10-29 12:29 ` Christian Biesinger
  0 siblings, 1 reply; 3+ messages in thread
From: Marten Ringwelski @ 2020-10-29  8:13 UTC (permalink / raw)
  To: gdb

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?

Thank you!
Marten Ringwelski

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Question] Is there a way to specify an offset to the loaded symbols?
  2020-10-29  8:13 [Question] Is there a way to specify an offset to the loaded symbols? Marten Ringwelski
@ 2020-10-29 12:29 ` Christian Biesinger
  2020-10-29 15:26   ` Marten Ringwelski
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Biesinger @ 2020-10-29 12:29 UTC (permalink / raw)
  To: Marten Ringwelski; +Cc: Reuben Thomas via Gdb

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Question] Is there a way to specify an offset to the loaded symbols?
  2020-10-29 12:29 ` Christian Biesinger
@ 2020-10-29 15:26   ` Marten Ringwelski
  0 siblings, 0 replies; 3+ messages in thread
From: Marten Ringwelski @ 2020-10-29 15:26 UTC (permalink / raw)
  To: Christian Biesinger, Marten Ringwelski; +Cc: Reuben Thomas via Gdb

On Thu Oct 29, 2020 at 2:29 PM CET, Christian Biesinger wrote:
> 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

Thank you, that was easier than expected!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-29 15:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29  8:13 [Question] Is there a way to specify an offset to the loaded symbols? Marten Ringwelski
2020-10-29 12:29 ` Christian Biesinger
2020-10-29 15:26   ` Marten Ringwelski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).