This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: gdbserver: Unexpected missing PT_PHDR when running break-interp.exp
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: GDB Patches <gdb-patches at sourceware dot org>
- Date: Sat, 3 Mar 2012 21:02:38 +0100
- Subject: Re: gdbserver: Unexpected missing PT_PHDR when running break-interp.exp
- References: <4F5114D0.5090707@redhat.com>
Hi Pedro,
On Fri, 02 Mar 2012 19:43:28 +0100, Pedro Alves wrote:
> GDB doesn't issue any warning in the (I think sort of) equivalent code
> in solib-svr4.c:read_program_header:
thanks for finding gdb/solib-svr4.c behaves slightly different than
gdbserver/linux-low.c in this regard. As it is fully safe to just ignore
PT_DYNAMIC in such case I think it is not worth changing in any of the two
implementations.
According to checking binaries on Fedora 16 x86_64 in practice this case
happens only for ld.so (/lib64/ld-linux-x86-64.so.2) - which does not have
DT_DEBUG anyway so it does not matter.
Off the top of my head I do not know what to do if some solution/relocation
would be needed.
Thanks,
Jan
2012-03-02 Pedro Alves <palves@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
* linux-low.c (get_dynamic): Don't warn when PT_PHDR isn't found.
New comment why.
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -5250,7 +5250,14 @@ get_dynamic (const int pid, const int is_elf64)
if (relocation == -1)
{
- warning ("Unexpected missing PT_PHDR");
+ /* PT_PHDR is optional, but necessary for PIE in general. Fortunately
+ any real world executables, including PIE executables, have always
+ PT_PHDR present. PT_PHDR is not present in some shared libraries or
+ in fpc (Free Pascal 2.4) binaries but neither of those have a need for
+ or present DT_DEBUG anyway (fpc binaries are statically linked).
+
+ Therefore if there exists DT_DEBUG there is always also PT_PHDR. */
+
return 0;
}