This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
PATCH: BZ #14557: __kernel_vsyscall unwind info is incorrect
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 20 Sep 2012 06:12:08 -0700
- Subject: PATCH: BZ #14557: __kernel_vsyscall unwind info is incorrect
Hi,
dl_iterate_phdr in libc.a doesn't take vDSO into account. As the
result, we can't unwind through __kernel_vsyscall. This patch adds
_dl_sysinfo_dso_phdr_info to recoard vDSO for static dl_iterate_phdr.
Tested on x86-64 and i686. OK to install?
Thanks.
H.J.
--
diff --git a/ChangeLog b/ChangeLog
index a77ef92..afa73e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-09-20 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #14557]
+ * elf/dl-iteratephdr.c (__dl_iterate_phdr): Use
+ _dl_sysinfo_dso_phdr_info in libc.a if needed.
+ * elf/dl-support.c: Include <assert.h>.
+ (_dl_sysinfo_dso_phdr_info): New.
+ (_dl_aux_init): Initialize _dl_sysinfo_dso_phdr_info in libc.a
+ if needed.
+
2012-09-19 Dmitry V. Levin <ldv@altlinux.org>
[BZ #14579]
diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c
index 95c2afd..94ba02a 100644
--- a/elf/dl-iteratephdr.c
+++ b/elf/dl-iteratephdr.c
@@ -78,6 +78,15 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
break;
}
+#if !defined SHARED && (defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO)
+ if (!ret && GLRO(dl_sysinfo_dso))
+ {
+ extern struct dl_phdr_info _dl_sysinfo_dso_phdr_info;
+ ret = callback (&_dl_sysinfo_dso_phdr_info,
+ sizeof (struct dl_phdr_info), data);
+ }
+#endif
+
/* Release the lock. */
__libc_cleanup_pop (0);
__rtld_lock_unlock_recursive (GL(dl_load_write_lock));
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 2bb468a..558e687 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -33,6 +33,7 @@
#include <unsecvars.h>
#include <hp-timing.h>
#include <stackinfo.h>
+#include <assert.h>
extern char *__progname;
char **_dl_argv = &__progname; /* This is checked for some error messages. */
@@ -161,6 +162,7 @@ uintptr_t _dl_sysinfo = DL_SYSINFO_DEFAULT;
#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
/* Address of the ELF headers in the vsyscall page. */
const ElfW(Ehdr) *_dl_sysinfo_dso;
+struct dl_phdr_info _dl_sysinfo_dso_phdr_info;
#endif
/* During the program run we must not modify the global data of
@@ -250,6 +252,29 @@ _dl_aux_init (ElfW(auxv_t) *av)
__libc_enable_secure = uid != 0 || gid != 0;
__libc_enable_secure_decided = 1;
}
+# if !defined SHARED && (defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO)
+ /* Set up the dl_phdr_info structure for the system-supplied virtual DSO. */
+ const ElfW(Ehdr) *const ehdr = GLRO(dl_sysinfo_dso);
+ if (ehdr != NULL)
+ {
+ /* GLRO(dl_sysinfo_dso) points to the virtual DSO ELF header. */
+ const ElfW(Phdr) *const phdr = (const void *) ehdr + ehdr->e_phoff;
+ _dl_sysinfo_dso_phdr_info.dlpi_phdr = phdr;
+ _dl_sysinfo_dso_phdr_info.dlpi_phnum = ehdr->e_phnum;
+ for (uint_fast16_t i = 0; i < ehdr->e_phnum; ++i)
+ {
+ const ElfW(Phdr) *const ph = &phdr[i];
+ /* Compute the base address from the PT_LOAD segment. */
+ if (ph->p_type == PT_LOAD)
+ {
+ assert (ph->p_offset == 0);
+ _dl_sysinfo_dso_phdr_info.dlpi_addr
+ = (ElfW(Addr)) ehdr - ph->p_vaddr;
+ break;
+ }
+ }
+ }
+# endif
}
#endif
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index ebb9048..0705e22 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,18 @@
+2012-09-20 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #14557]
+ * Makefile (tests-static): Add tst-cancel24-static
+ tst-cond8-static tst-mutex8-static tst-mutexpi8-static
+ tst-sem11-static tst-sem12-static.
+ (tests): Likewise.
+ (LDLIBS-tst-cancel24-static): New macro.
+ * tst-cancel24-static.cc: New file.
+ * tst-cond8-static.c: Likewise.
+ * tst-mutex8-static.c: Likewise.
+ * tst-mutexpi8-static.c: Likewise.
+ * tst-sem11-static.c: Likewise.
+ * tst-sem12-static.c: Likewise.
+
2012-09-19 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/i386/tls.h (THREAD_SETMEM): Cast to uint64_t for
diff --git a/nptl/Makefile b/nptl/Makefile
index 6f2b66c..9842bee 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -349,8 +349,12 @@ link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
$(common-objpfx)libc.a
tests-static += tst-locale1 tst-locale2 tst-stackguard1-static \
- tst-cancel21-static
-tests += tst-stackguard1-static tst-cancel21-static
+ tst-cancel21-static tst-cancel24-static tst-cond8-static \
+ tst-mutex8-static tst-mutexpi8-static tst-sem11-static \
+ tst-sem12-static
+tests += tst-stackguard1-static tst-cancel21-static tst-cancel24-static \
+ tst-cond8-static tst-mutex8-static tst-mutexpi8-static \
+ tst-sem11-static tst-sem12-static
xtests-static += tst-setuid1-static
# These tests are linked with libc before libpthread
@@ -508,6 +512,7 @@ $(objpfx)tst-rwlock14: $(common-objpfx)rt/librt.a
endif
LDLIBS-tst-cancel24 = $(no-as-needed) -lstdc++
+LDLIBS-tst-cancel24-static = $(no-as-needed) -lstdc++
extra-B-pthread.so = -B$(common-objpfx)nptl/
$(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
diff --git a/nptl/tst-cancel24-static.cc b/nptl/tst-cancel24-static.cc
new file mode 100644
index 0000000..3f97de5
--- /dev/null
+++ b/nptl/tst-cancel24-static.cc
@@ -0,0 +1 @@
+#include "tst-cancel24.cc"
diff --git a/nptl/tst-cond8-static.c b/nptl/tst-cond8-static.c
new file mode 100644
index 0000000..fed35db
--- /dev/null
+++ b/nptl/tst-cond8-static.c
@@ -0,0 +1 @@
+#include "tst-cond8.c"
diff --git a/nptl/tst-mutex8-static.c b/nptl/tst-mutex8-static.c
new file mode 100644
index 0000000..d69ed49
--- /dev/null
+++ b/nptl/tst-mutex8-static.c
@@ -0,0 +1 @@
+#include "tst-mutex8.c"
diff --git a/nptl/tst-mutexpi8-static.c b/nptl/tst-mutexpi8-static.c
new file mode 100644
index 0000000..869e6df
--- /dev/null
+++ b/nptl/tst-mutexpi8-static.c
@@ -0,0 +1 @@
+#include "tst-mutexpi8.c"
diff --git a/nptl/tst-sem11-static.c b/nptl/tst-sem11-static.c
new file mode 100644
index 0000000..09b7698
--- /dev/null
+++ b/nptl/tst-sem11-static.c
@@ -0,0 +1 @@
+#include "tst-sem11.c"
diff --git a/nptl/tst-sem12-static.c b/nptl/tst-sem12-static.c
new file mode 100644
index 0000000..c06349f
--- /dev/null
+++ b/nptl/tst-sem12-static.c
@@ -0,0 +1 @@
+#include "tst-sem12.c"