From 23b0e13d2e32c255ea8389bf07557e5d6fcad198 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Sat, 1 Mar 2003 11:02:44 +0000 Subject: Teach ldd to act just the glibc provided one (relying on the shared lib loader to do the work) when it is possible to do so, and only go poking about through the ELF headers when that fails so we can still use 'ldd' on cross compiled stuff. -Erik --- ldso/ldso/ldso.c | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'ldso/ldso/ldso.c') diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index d365a38c3..7340f4ead 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -931,21 +931,18 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a #ifdef __LDSO_LDD_SUPPORT__ if (_dl_trace_loaded_objects) _dl_dprintf(1, "\t%s => not found\n", str); - else { + else #endif - _dl_dprintf(2, "%s: can't load " - "library '%s'\n", _dl_progname, str); + { + _dl_dprintf(2, "%s: can't load " "library '%s'\n", _dl_progname, str); _dl_exit(15); -#ifdef __LDSO_LDD_SUPPORT__ } -#endif } else { #ifdef __SUPPORT_LD_DEBUG_EARLY__ _dl_dprintf(_dl_debug_file, "Loading:\t(%x) %s\n", tpnt1->loadaddr, tpnt1->libname); #endif #ifdef __LDSO_LDD_SUPPORT__ - if (_dl_trace_loaded_objects - && tpnt1->usage_count==1) { + if (_dl_trace_loaded_objects && tpnt1->usage_count==1) { /* this is a real hack to make ldd not print * the library itself when run on a library. */ if (_dl_strcmp(_dl_progname, str) != 0) @@ -1010,21 +1007,18 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a #ifdef __LDSO_LDD_SUPPORT__ if (_dl_trace_loaded_objects) _dl_dprintf(1, "\t%s => not found\n", cp2); - else { + else #endif - _dl_dprintf(2, "%s: can't load library '%s'\n", - _dl_progname, cp2); + { + _dl_dprintf(2, "%s: can't load library '%s'\n", _dl_progname, cp2); _dl_exit(15); -#ifdef __LDSO_LDD_SUPPORT__ } -#endif } else { #ifdef __SUPPORT_LD_DEBUG_EARLY__ _dl_dprintf(_dl_debug_file, "Loading:\t(%x) %s\n", tpnt1->loadaddr, tpnt1->libname); #endif #ifdef __LDSO_LDD_SUPPORT__ - if (_dl_trace_loaded_objects - && tpnt1->usage_count==1) { + if (_dl_trace_loaded_objects && tpnt1->usage_count==1) { _dl_dprintf(1, "\t%s => %s (0x%x)\n", cp2, tpnt1->libname, (unsigned) tpnt1->loadaddr); } @@ -1086,13 +1080,12 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a #ifdef __LDSO_LDD_SUPPORT__ if (_dl_trace_loaded_objects) _dl_dprintf(1, "\t%s => not found\n", lpntstr); - else { + else #endif + { _dl_dprintf(2, "%s: can't load library '%s'\n", _dl_progname, lpntstr); _dl_exit(16); -#ifdef __LDSO_LDD_SUPPORT__ } -#endif } else { #ifdef __SUPPORT_LD_DEBUG_EARLY__ _dl_dprintf(_dl_debug_file, "Loading:\t(%x) %s\n", tpnt1->loadaddr, tpnt1->libname); @@ -1111,15 +1104,6 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a #ifdef USE_CACHE _dl_unmap_cache(); #endif - /* ldd uses uses this. I am not sure how you pick up the other flags */ -#ifdef __LDSO_LDD_SUPPORT__ - if (_dl_trace_loaded_objects) { - char *_dl_warn = 0; - _dl_warn = _dl_getenv("LD_WARN", envp); - if (!_dl_warn) - _dl_exit(0); - } -#endif /* * If the program interpreter is not in the module chain, add it. This will @@ -1154,7 +1138,9 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a rpnt->dyn = tpnt; tpnt = NULL; } + #ifdef __LDSO_LDD_SUPPORT__ + /* End of the line for ldd.... */ if (_dl_trace_loaded_objects) { _dl_dprintf(1, "\t%s => %s (0x%x)\n", rpnt->dyn->libname + (_dl_strlen(_dl_ldsopath)) + 1, rpnt->dyn->libname, rpnt->dyn->loadaddr); @@ -1162,6 +1148,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a } #endif + #ifdef __mips__ /* * Relocation of the GOT entries for MIPS have to be done @@ -1190,10 +1177,6 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a #endif if (_dl_symbol_tables) goof += _dl_copy_fixups(_dl_symbol_tables); -#ifdef __LDSO_LDD_SUPPORT__ - if (goof || _dl_trace_loaded_objects) - _dl_exit(0); -#endif /* OK, at this point things are pretty much ready to run. Now we need to touch up a few items that are required, and then -- cgit v1.2.3