This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/11440] New: attach to PIE from valgrind if ld.so is unprelinked


This is a tracker for:

https://bugs.kde.org/show_bug.cgi?id=223702
--db-command should support %{auxv address}

------------------------------------------------------------------------------

valgrind --db-attach pie-executable
does not currently work if /lib64/ld*.so is not prelinked.

FSF GDB support for PIE (Position Independent Executable; built using -fPIE
-pie) debugging has been checked-in to CVS HEAD (->gdb-7.1):
http://sourceware.org/ml/gdb-patches/2010-01/msg00233.html

It currently works for all these cases (simplified):
gdb -p normal-executable
gdb -p pie-executable-prelinked
gdb -p pie-executable-unprelinked
valgrind --db-attach normal-executable
valgrind --db-attach pie-executable-prelinked-only-if-ld.so-is-prelinked
valgrind --db-attach pie-executable-unprelinked-only-if-ld.so-is-prelinked

It does not work for:
valgrind --db-attach pie-executable-prelinked-only-if-ld.so-is-unprelinked
valgrind --db-attach pie-executable-unprelinked-only-if-ld.so-is-unprelinked

GDB generally wants to know AUXV of the debugged process.  With AUXV and its
AT_ENTRY value it can find the executable offset and relocate its symbols for
it.

Normally /proc/PID/auxv is read to find the AUXV content.  But with valgrind it
does not match, therefore for attachments it rather uses "_dl_auxv" (located in
ld.so).  GDB cannot use backtrace from main to _start to find the
valgrind-modified auxv there as the initial thread may have exited (+it would
be too fragile anyway).

But to locate "_dl_auxv" we need relocated symbols for ld.so which is a
chicked-and-egg problem.  DT_DEBUG
is in the main executable (which would point us at ld.so load address) but we
need AUXV to find out how to relocate symbols for the PIE main executable.

Therefore we known neither the main executable offset (as it is PIE) and
therefore neither DT_DEBUG and therefore neither ld.so offset (as it is PIC and
not prelinked loaded at arbitrary address) and therefore neither "_dl_auxv"
offset and /proc/PID/auxv is invalid with valgrind attachments.  There is
everything floating.

Therefore suggesting to create besides %f and %p --db-command substitutions
also some %a producing string "0x7fffffffd7e0" which would correspond to
"the_iifii.client_auxv" (or where is the AUXV address stored).  GDB will get
corresponding "--auxv" commandline option / CLI setting.  Thanks.

-- 
           Summary: attach to PIE from valgrind if ld.so is unprelinked
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: gdb
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: jan dot kratochvil at redhat dot com
                CC: gdb-prs at sourceware dot org


http://sourceware.org/bugzilla/show_bug.cgi?id=11440

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]