Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Handle absence of DT_DEBUG while debugging ld.so
@ 2008-07-28 23:55 Luis Machado
  2008-07-29  2:27 ` Daniel Jacobowitz
  0 siblings, 1 reply; 9+ messages in thread
From: Luis Machado @ 2008-07-28 23:55 UTC (permalink / raw)
  To: gdb-patches

Hi folks,

When trying to debug ld.so, we may find that the DT_DEBUG entry in
the .dynamic section is missing, thus GDB tries to look for the _r_debug
minimal symbol, and eventually finds it. This works OK as long as the
_r_debug minimal symbol is correct and initialized.

In the case where GDB fetches an uninitialized _r_debug minimal symbol
and tries to access its address, we have a memory access error, just
like below:

(gdb) r
Starting program: /foo/lib/ld.so.1
Cannot access memory at address 0x2f648

Thus, we should guard this piece of code against uninitialized addresses
so that GDB can skip this entry and look for another (hopefully) valid
_r_debug symbol.

Tested against HEAD for ppc32/ppc64 with no regressions. OK?

Regards,
Luis

---
2008-07-28  Luis Machado  <luisgpm@br.ibm.com>

	* solib-svr4.c (elf_locate_base): Check if msymbol's
	address is valid.

Index: gdb/solib-svr4.c
===================================================================
--- gdb.orig/solib-svr4.c	2008-07-28 14:35:20.000000000 -0700
+++ gdb/solib-svr4.c	2008-07-28 16:11:42.000000000 -0700
@@ -508,9 +508,14 @@
     return dyn_ptr;
 
   /* This may be a static executable.  Look for the symbol
-     conventionally named _r_debug, as a last resort.  */
+     conventionally named _r_debug, as a last resort and check if
+     the address contained in the minimal symbol is valid before
+     proceeding.  */
   msymbol = lookup_minimal_symbol ("_r_debug", NULL, symfile_objfile);
-  if (msymbol != NULL)
+  if (msymbol != NULL
+      && !target_read_memory (SYMBOL_VALUE_ADDRESS (msymbol),
+			      (gdb_byte *)&dyn_ptr,
+			      TYPE_LENGTH (builtin_type_void_data_ptr)))
     return SYMBOL_VALUE_ADDRESS (msymbol);
 
   /* DT_DEBUG entry not found.  */



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

end of thread, other threads:[~2008-09-05 18:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-28 23:55 [PATCH] Handle absence of DT_DEBUG while debugging ld.so Luis Machado
2008-07-29  2:27 ` Daniel Jacobowitz
2008-07-29  2:57   ` Luis Machado
2008-07-29  3:03     ` Luis Machado
2008-07-29 12:13     ` Daniel Jacobowitz
2008-07-29 12:46       ` Luis Machado
2008-08-12 18:16         ` Luis Machado
2008-09-05 18:31           ` Luis Machado
2008-07-29 12:55       ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox