[PATCH RFA] solib-svr4.c patch for dynamic executables

Ulrich Drepper drepper@redhat.com
Wed Nov 8 09:34:00 GMT 2000


Jim Blandy <jimb@cygnus.com> writes:

> If I'm debugging a process created by applying `exec' to a binary
> whose e_type == ET_DYN, how can I find the base address the kernel
> chose?

Just as Kevin did it:

- have the ptrace() flag set before exec()ing

- get control of the child before executing the first instruction (the
  kernel does this for you)

- get the IP value

- substract from IP the e_entry value from the ELF header


If the DSO is not meant to be executed the e_entry field has some wild
content (mostly zero) but who cares?  gdb still can handle the binary
but the application will crash right after it is started.  Exactly
what should happen.

Please note that you can execute DSO even if they have an PT_INTERP
entry (libdl.so on Linux is such an example).  I wouldn't have
complained about not being able to debug this with Kevin's patch since
it's not really important.  But still.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------


More information about the Gdb-patches mailing list