[git commit ldso-future 1/1] ldso/debug: move _dl_debug* initialization to dl-debug.c
Peter S. Mazinger
ps.m at gmx.net
Wed Mar 30 11:53:36 UTC 2011
commit: http://git.uclibc.org/uClibc/commit/?id=e02dda95a7a531e835bbd86a3f122436d6fd5294
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/ldso-future
While there, constify in dl-debug.c.
Remove fallbacks debug_sym and debug_reloc, provide them in a header,
this way dl-debug.c has to be included only if LD_DEBUG is enabled.
Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
ldso/ldso/dl-debug.c | 34 ++++++++++++++++++----------------
ldso/ldso/ldso.c | 11 -----------
ldso/libdl/libdl.c | 10 ----------
3 files changed, 18 insertions(+), 37 deletions(-)
diff --git a/ldso/ldso/dl-debug.c b/ldso/ldso/dl-debug.c
index 02eb15a..47e4c2f 100644
--- a/ldso/ldso/dl-debug.c
+++ b/ldso/ldso/dl-debug.c
@@ -39,25 +39,35 @@
#include <ldso.h>
-#if defined (__SUPPORT_LD_DEBUG__)
+#ifdef __SUPPORT_LD_DEBUG__
/* include the arch-specific _dl_reltypes_tab */
-#include "dl-debug.h"
+#include <dl-debug.h>
+
+#if defined IS_IN_rtld || !defined SHARED
+char *_dl_debug = NULL;
+char *_dl_debug_symbols = NULL;
+char *_dl_debug_move = NULL;
+char *_dl_debug_reloc = NULL;
+char *_dl_debug_detail = NULL;
+char *_dl_debug_nofixups = NULL;
+char *_dl_debug_bindings = NULL;
+int _dl_debug_file = 2;
+#endif
static const char *_dl_reltypes(int type)
{
static char buf[50];
const char *str;
- int tabsize;
- tabsize = (int)(sizeof(_dl_reltypes_tab) / sizeof(_dl_reltypes_tab[0]));
+ const int tabsize = (int)(sizeof(_dl_reltypes_tab) / sizeof(_dl_reltypes_tab[0]));
if (type >= tabsize || (str = _dl_reltypes_tab[type]) == NULL)
str = _dl_simple_ltoa(buf, (unsigned long)type);
return str;
}
-static void debug_sym(const ElfW(Sym) *const symtab, const char *strtab, const int symtab_index)
+static void __attribute_used__ debug_sym(const ElfW(Sym) *const symtab, const char *strtab, const int symtab_index)
{
if (!_dl_debug_symbols || !symtab_index)
return;
@@ -72,7 +82,7 @@ static void debug_sym(const ElfW(Sym) *const symtab, const char *strtab, const i
symtab[symtab_index].st_shndx);
}
-static void debug_reloc(const ElfW(Sym) *const symtab, const char *strtab, const ELF_RELOC *const rpnt)
+static void __attribute_used__ debug_reloc(const ElfW(Sym) *const symtab, const char *strtab, const ELF_RELOC *const rpnt)
{
if (!_dl_debug_reloc)
return;
@@ -80,11 +90,8 @@ static void debug_reloc(const ElfW(Sym) *const symtab, const char *strtab, const
if (_dl_debug_symbols) {
_dl_dprintf(_dl_debug_file, "\n\t");
} else {
- int symtab_index;
- const char *sym;
-
- symtab_index = ELF_R_SYM(rpnt->r_info);
- sym = symtab_index ? strtab + symtab[symtab_index].st_name : "sym=0x0";
+ const int symtab_index = ELF_R_SYM(rpnt->r_info);
+ const char *sym = symtab_index ? strtab + symtab[symtab_index].st_name : "sym=0x0";
_dl_dprintf(_dl_debug_file, "\n%s\n\t", sym);
}
@@ -98,9 +105,4 @@ static void debug_reloc(const ElfW(Sym) *const symtab, const char *strtab, const
_dl_dprintf(_dl_debug_file, "\n");
}
-#else
-
-#define debug_sym(symtab, strtab, symtab_index)
-#define debug_reloc(symtab, strtab, rpnt)
-
#endif /* __SUPPORT_LD_DEBUG__ */
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 0dfd901..2f5c879 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -59,17 +59,6 @@ void (*_dl_free_function) (void *p) = NULL;
static int _dl_secure = 1; /* Are we dealing with setuid stuff? */
-#ifdef __SUPPORT_LD_DEBUG__
-char *_dl_debug = NULL;
-char *_dl_debug_symbols = NULL;
-char *_dl_debug_move = NULL;
-char *_dl_debug_reloc = NULL;
-char *_dl_debug_detail = NULL;
-char *_dl_debug_nofixups = NULL;
-char *_dl_debug_bindings = NULL;
-int _dl_debug_file = 2;
-#endif
-
/* Needed for standalone execution. */
unsigned long attribute_hidden _dl_skip_args = 0;
const char *_dl_progname = UCLIBC_LDSO; /* The name of the executable being run */
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index f4dc289..66190df 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -87,16 +87,6 @@ extern char *_dl_debug;
/* When libdl is linked as a static library, we need to replace all
* the symbols that otherwise would have been loaded in from ldso... */
-#ifdef __SUPPORT_LD_DEBUG__
-char *_dl_debug = NULL;
-char *_dl_debug_symbols = NULL;
-char *_dl_debug_move = NULL;
-char *_dl_debug_reloc = NULL;
-char *_dl_debug_detail = NULL;
-char *_dl_debug_nofixups = NULL;
-char *_dl_debug_bindings = NULL;
-int _dl_debug_file = 2;
-#endif
const char *_dl_progname = ""; /* Program name */
void *(*_dl_malloc_function)(size_t);
void (*_dl_free_function) (void *p);
--
1.7.3.4
More information about the uClibc-cvs
mailing list