This is the mail archive of the
mailing list for the glibc project.
[PATCH] Initialize _r_debug for static applications.
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Cc: Jan Kratochvil <jan dot kratochvil at redhat dot com>, "Maciej W. Rozycki" <macro at codesourcery dot com>, Roland McGrath <roland at hack dot frob dot com>
- Date: Thu, 10 Apr 2014 20:06:54 -0400
- Subject: [PATCH] Initialize _r_debug for static applications.
- Authentication-results: sourceware.org; auth=none
With Maciej's great work on reducing the difference between
static and dyanmic executables, and with the addition of
a functional main link map in static exectuables we can now
usefully initialize _r_debug for static applications. This
will allow future debuggers the ability to coalesce code
paths which previously had to have special cases for static
It also fixes this particular use case where gdb would like
a consistent way to find the application link map for looking
up TLS variables in both static and dynamic applications:
The discussion touches on the fact that without _r_debug the
debugger has to make various assupmtions while using
libthread_db that contrains the implementation.
This patch initializes the debug infrastructure during
LIBC_START_MAIN, but only for static applications, by
calling `_dl_debug_initialize (0, LM_ID_BASE)'. We pass 0 as
the ldbase because it's a static application, and the runtime
address of the loader doesn't matter. We pass LM_ID_BASE because
we want to load, by default, the base link map, and that's what
Tested on x86_64 with no regressions.
Jan reports this works and that gdb can be patched to use
_r_debug to access TLS variables in static applications
while still using the current libthread_db calls normally
used for dynamic applications.
This removes one more difference between static and dynamic
Note: This does not attempt to cleanup the -Wundef warning
for SHARED, which I am looking to fix in another patch so
we still use `#ifndef SHARED' (Makeconfig needs to be fixed
to use -DSHARED=0 and -DSHARED=1 IMO to make this work correctly).
OK to checkin?
2014-04-10 Carlos O'Donell <firstname.lastname@example.org>
* csu/libc-start.c (LIBC_START_MAIN) [!SHARED]: Call
diff --git a/csu/libc-start.c b/csu/libc-start.c
index 3b7092b..d571a1a 100644
@@ -264,6 +264,9 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
GLRO(dl_debug_printf) ("\ntransferring control: %s\n\n", argv);
+ _dl_debug_initialize (0, LM_ID_BASE);
/* Memory for the cancellation buffer. */
struct pthread_unwind_buf unwind_buf;