Root/toolchain/uClibc/patches-0.9.32/130-ldso-fix-__dl_parse_dynamic_info-segfault.patch

1[PATCH] ld.so: ldd crashes when __LDSO_SEARCH_INTERP_PATH__ is not #defined
2Since b65c7b2c79debcb9017e31913e01eeaa280106fb, the implicit search path
3can be disabled by not #defining __LDSO_SEARCH_INTERP_PATH__. This
4causes _dl_ldsopath to never be set, so it remains NULL. _dl_ldsopath is
5still used when __LDSO_LDD_SUPPORT__ is #defined, to strip the path off
6of the beginning of the absolute path to the ld.so interpreter in use
7for printing. The _dl_strlen will crash with a NULL argument.
8
9Rather than relying on _dl_ldsopath, this change causes ldd to compute
10the interpreter's basename directly.
11
12glibc ld.so seems to print the full path to the interpreter without
13any computed basename or =>. I personally prefer glibc's behavior, but
14to preserve backwards compatibility with uClibc ld.so, the existing
15format with the computed basename, =>, and full path is used here. This
16enables simpler (and unchanged) text processing in a pipeline.
17
18Signed-off-by: Mark Mentovai <mark at moxienet.com>
19---
20ldso/ldso/ldso.c | 12 +++++++++---
21--- a/ldso/ldso/ldso.c
22+++ b/ldso/ldso/ldso.c
23@@ -920,9 +920,15 @@
24 #ifdef __LDSO_LDD_SUPPORT__
25     /* End of the line for ldd.... */
26     if (trace_loaded_objects) {
27- _dl_dprintf(1, "\t%s => %s (%x)\n",
28- rpnt->dyn->libname + _dl_strlen(_dl_ldsopath) + 1,
29- rpnt->dyn->libname, DL_LOADADDR_BASE(rpnt->dyn->loadaddr));
30+ /* glibc ld.so/ldd would just do
31+ * _dl_dprintf(1, "\t%s (%x)\n", rpnt->dyn->libname,
32+ * DL_LOADADDR_BASE(rpnt->dyn->loadaddr));
33+ * but uClibc has always used the => format. */
34+ char *ptmp = _dl_strrchr(rpnt->dyn->libname, '/');
35+ if (ptmp != rpnt->dyn->libname)
36+ ++ptmp;
37+ _dl_dprintf(1, "\t%s => %s (%x)\n", ptmp, rpnt->dyn->libname,
38+ DL_LOADADDR_BASE(rpnt->dyn->loadaddr));
39         _dl_exit(0);
40     }
41 #endif
42

Archive Download this file



interactive