From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>,
jjohnstn@redhat.com, ezannoni@redhat.com
Subject: [PATCH] Move DT_DEBUG initialization earlier in dl_main
Date: Mon, 13 Jun 2005 17:14:00 -0000 [thread overview]
Message-ID: <20050613171435.GI7663@sunsite.mff.cuni.cz> (raw)
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
next reply other threads:[~2005-06-13 17:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-13 17:14 Jakub Jelinek [this message]
2005-06-13 22:57 ` Ulrich Drepper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050613171435.GI7663@sunsite.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=ezannoni@redhat.com \
--cc=jjohnstn@redhat.com \
--cc=libc-hacker@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).