public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Move DT_DEBUG initialization earlier in dl_main
@ 2005-06-13 17:14 Jakub Jelinek
  2005-06-13 22:57 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2005-06-13 17:14 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers, jjohnstn, ezannoni

Hi!

gdb can't debug PIE binaries without this, because it will see DT_DEBUG
being NULL the first time it is notified.

2005-06-13  Jakub Jelinek  <jakub@redhat.com>

	* elf/rtld.c (dl_main): Move DT_DEBUG setup before first
	_dl_debug_state call.

--- libc/elf/rtld.c.jj	2005-05-26 14:21:09.000000000 +0200
+++ libc/elf/rtld.c	2005-06-13 18:59:11.000000000 +0200
@@ -1540,6 +1540,30 @@ ERROR: ld.so: object '%s' cannot be load
 	}
     }
 
+  {
+    struct link_map *l = main_map;
+
+#ifdef ELF_MACHINE_DEBUG_SETUP
+
+    /* Some machines (e.g. MIPS) don't use DT_DEBUG in this way.  */
+
+    ELF_MACHINE_DEBUG_SETUP (l, r);
+    ELF_MACHINE_DEBUG_SETUP (&GL(dl_rtld_map), r);
+
+#else
+
+    if (l->l_info[DT_DEBUG] != NULL)
+      /* There is a DT_DEBUG entry in the dynamic section.  Fill it in
+	 with the run-time address of the r_debug structure  */
+      l->l_info[DT_DEBUG]->d_un.d_ptr = (ElfW(Addr)) r;
+
+    /* Fill in the pointer in the dynamic linker's own dynamic section, in
+       case you run gdb on the dynamic linker directly.  */
+    if (GL(dl_rtld_map).l_info[DT_DEBUG] != NULL)
+      GL(dl_rtld_map).l_info[DT_DEBUG]->d_un.d_ptr = (ElfW(Addr)) r;
+#endif
+  }
+
   /* We start adding objects.  */
   r->r_state = RT_ADD;
   _dl_debug_state ();
@@ -2058,30 +2082,6 @@ ERROR: ld.so: object '%s' cannot be load
     }
 
 
-  {
-    struct link_map *l = main_map;
-
-#ifdef ELF_MACHINE_DEBUG_SETUP
-
-    /* Some machines (e.g. MIPS) don't use DT_DEBUG in this way.  */
-
-    ELF_MACHINE_DEBUG_SETUP (l, r);
-    ELF_MACHINE_DEBUG_SETUP (&GL(dl_rtld_map), r);
-
-#else
-
-    if (l->l_info[DT_DEBUG] != NULL)
-      /* There is a DT_DEBUG entry in the dynamic section.  Fill it in
-	 with the run-time address of the r_debug structure  */
-      l->l_info[DT_DEBUG]->d_un.d_ptr = (ElfW(Addr)) r;
-
-    /* Fill in the pointer in the dynamic linker's own dynamic section, in
-       case you run gdb on the dynamic linker directly.  */
-    if (GL(dl_rtld_map).l_info[DT_DEBUG] != NULL)
-      GL(dl_rtld_map).l_info[DT_DEBUG]->d_un.d_ptr = (ElfW(Addr)) r;
-#endif
-  }
-
   /* Now set up the variable which helps the assembler startup code.  */
   GL(dl_ns)[LM_ID_BASE]._ns_main_searchlist = &main_map->l_searchlist;
   GL(dl_ns)[LM_ID_BASE]._ns_global_scope[0] = &main_map->l_searchlist;

	Jakub

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

* Re: [PATCH] Move DT_DEBUG initialization earlier in dl_main
  2005-06-13 17:14 [PATCH] Move DT_DEBUG initialization earlier in dl_main Jakub Jelinek
@ 2005-06-13 22:57 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2005-06-13 22:57 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers, jjohnstn, ezannoni

[-- Attachment #1: Type: text/plain, Size: 120 bytes --]

Applied after some cleanup.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

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

end of thread, other threads:[~2005-06-13 22:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-13 17:14 [PATCH] Move DT_DEBUG initialization earlier in dl_main Jakub Jelinek
2005-06-13 22:57 ` Ulrich Drepper

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).