|
|
29e444 |
From a06663ebed17775761f501e5f0cdddff159959ac Mon Sep 17 00:00:00 2001
|
|
|
29e444 |
From: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
|
|
|
29e444 |
Date: Tue, 23 Jul 2013 07:39:57 -0500
|
|
|
29e444 |
Subject: [PATCH 42/42] PowerPC: use _dl_static_init to set GLRO(gl_pagesize)
|
|
|
29e444 |
|
|
|
29e444 |
This patch fixes dlfcn/tststatic5 for PowerPC where pagesize
|
|
|
29e444 |
variable was not properly initialized in certain cases. This patch
|
|
|
29e444 |
is based on other architecture code.
|
|
|
29e444 |
(cherry picked from commit 7b1f8b581f9387230788e4d8a67cdbcf464dac85)
|
|
|
29e444 |
---
|
|
|
29e444 |
sysdeps/unix/sysv/linux/powerpc/Makefile | 6 +++
|
|
|
29e444 |
sysdeps/unix/sysv/linux/powerpc/Versions | 6 +++
|
|
|
29e444 |
sysdeps/unix/sysv/linux/powerpc/dl-static.c | 84 +++++++++++++++++++++++++++++
|
|
|
29e444 |
sysdeps/unix/sysv/linux/powerpc/ldsodefs.h | 33 ++++++++++++
|
|
|
29e444 |
5 files changed, 137 insertions(+)
|
|
|
29e444 |
create mode 100644 sysdeps/unix/sysv/linux/powerpc/dl-static.c
|
|
|
29e444 |
create mode 100644 sysdeps/unix/sysv/linux/powerpc/ldsodefs.h
|
|
|
29e444 |
|
|
|
12745e |
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/Makefile glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/Makefile
|
|
|
29e444 |
index 4ff7e84..cf4de97 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/Makefile
|
|
|
12745e |
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/Makefile
|
|
|
29e444 |
@@ -15,6 +15,12 @@ endif
|
|
|
29e444 |
|
|
|
29e444 |
ifeq ($(subdir),elf)
|
|
|
29e444 |
sysdep_routines += dl-vdso
|
|
|
29e444 |
+ifeq ($(build-shared),yes)
|
|
|
29e444 |
+# This is needed for DSO loading from static binaries.
|
|
|
29e444 |
+sysdep-dl-routines += dl-static
|
|
|
29e444 |
+sysdep_routines += dl-static
|
|
|
29e444 |
+sysdep-rtld-routines += dl-static
|
|
|
29e444 |
+endif
|
|
|
29e444 |
endif
|
|
|
29e444 |
|
|
|
29e444 |
ifeq ($(subdir),misc)
|
|
|
12745e |
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/Versions glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/Versions
|
|
|
29e444 |
index 289c4fe..9b583fb 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/Versions
|
|
|
12745e |
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/Versions
|
|
|
29e444 |
@@ -1,3 +1,9 @@
|
|
|
29e444 |
+ld {
|
|
|
29e444 |
+ GLIBC_PRIVATE {
|
|
|
29e444 |
+ # used for loading by static libraries
|
|
|
29e444 |
+ _dl_var_init;
|
|
|
29e444 |
+ }
|
|
|
29e444 |
+}
|
|
|
29e444 |
libc {
|
|
|
29e444 |
GLIBC_PRIVATE {
|
|
|
29e444 |
__vdso_get_tbfreq;
|
|
|
12745e |
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/dl-static.c glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/dl-static.c
|
|
|
29e444 |
new file mode 100644
|
|
|
29e444 |
index 0000000..8289c61
|
|
|
29e444 |
--- /dev/null
|
|
|
12745e |
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/dl-static.c
|
|
|
29e444 |
@@ -0,0 +1,84 @@
|
|
|
29e444 |
+/* Variable initialization. PowerPC version.
|
|
|
29e444 |
+ Copyright (C) 2013 Free Software Foundation, Inc.
|
|
|
29e444 |
+ This file is part of the GNU C Library.
|
|
|
29e444 |
+
|
|
|
29e444 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
29e444 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
29e444 |
+ License as published by the Free Software Foundation; either
|
|
|
29e444 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
29e444 |
+
|
|
|
29e444 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
29e444 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
29e444 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
29e444 |
+ Lesser General Public License for more details.
|
|
|
29e444 |
+
|
|
|
29e444 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
29e444 |
+ License along with the GNU C Library. If not, see
|
|
|
29e444 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
29e444 |
+
|
|
|
29e444 |
+#include <ldsodefs.h>
|
|
|
29e444 |
+
|
|
|
29e444 |
+#ifdef SHARED
|
|
|
29e444 |
+
|
|
|
29e444 |
+void
|
|
|
29e444 |
+_dl_var_init (void *array[])
|
|
|
29e444 |
+{
|
|
|
29e444 |
+ /* It has to match "variables" below. */
|
|
|
29e444 |
+ enum
|
|
|
29e444 |
+ {
|
|
|
29e444 |
+ DL_PAGESIZE = 0
|
|
|
29e444 |
+ };
|
|
|
29e444 |
+
|
|
|
29e444 |
+ GLRO(dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
|
|
|
29e444 |
+}
|
|
|
29e444 |
+
|
|
|
29e444 |
+#else
|
|
|
29e444 |
+
|
|
|
29e444 |
+static void *variables[] =
|
|
|
29e444 |
+{
|
|
|
29e444 |
+ &GLRO(dl_pagesize)
|
|
|
29e444 |
+};
|
|
|
29e444 |
+
|
|
|
29e444 |
+static void
|
|
|
29e444 |
+_dl_unprotect_relro (struct link_map *l)
|
|
|
29e444 |
+{
|
|
|
29e444 |
+ ElfW(Addr) start = ((l->l_addr + l->l_relro_addr)
|
|
|
29e444 |
+ & ~(GLRO(dl_pagesize) - 1));
|
|
|
29e444 |
+ ElfW(Addr) end = ((l->l_addr + l->l_relro_addr + l->l_relro_size)
|
|
|
29e444 |
+ & ~(GLRO(dl_pagesize) - 1));
|
|
|
29e444 |
+
|
|
|
29e444 |
+ if (start != end)
|
|
|
29e444 |
+ __mprotect ((void *) start, end - start, PROT_READ | PROT_WRITE);
|
|
|
29e444 |
+}
|
|
|
29e444 |
+
|
|
|
29e444 |
+void
|
|
|
29e444 |
+_dl_static_init (struct link_map *l)
|
|
|
29e444 |
+{
|
|
|
29e444 |
+ struct link_map *rtld_map = l;
|
|
|
29e444 |
+ struct r_scope_elem **scope;
|
|
|
29e444 |
+ const ElfW(Sym) *ref = NULL;
|
|
|
29e444 |
+ lookup_t loadbase;
|
|
|
29e444 |
+ void (*f) (void *[]);
|
|
|
29e444 |
+ size_t i;
|
|
|
29e444 |
+
|
|
|
29e444 |
+ loadbase = _dl_lookup_symbol_x ("_dl_var_init", l, &ref, l->l_local_scope,
|
|
|
29e444 |
+ NULL, 0, 1, NULL);
|
|
|
29e444 |
+
|
|
|
29e444 |
+ for (scope = l->l_local_scope; *scope != NULL; scope++)
|
|
|
29e444 |
+ for (i = 0; i < (*scope)->r_nlist; i++)
|
|
|
29e444 |
+ if ((*scope)->r_list[i] == loadbase)
|
|
|
29e444 |
+ {
|
|
|
29e444 |
+ rtld_map = (*scope)->r_list[i];
|
|
|
29e444 |
+ break;
|
|
|
29e444 |
+ }
|
|
|
29e444 |
+
|
|
|
29e444 |
+ if (ref != NULL)
|
|
|
29e444 |
+ {
|
|
|
29e444 |
+ f = (void (*) (void *[])) DL_SYMBOL_ADDRESS (loadbase, ref);
|
|
|
29e444 |
+ _dl_unprotect_relro (rtld_map);
|
|
|
29e444 |
+ f (variables);
|
|
|
29e444 |
+ _dl_protect_relro (rtld_map);
|
|
|
29e444 |
+ }
|
|
|
29e444 |
+}
|
|
|
29e444 |
+
|
|
|
29e444 |
+#endif
|
|
|
12745e |
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/ldsodefs.h glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/ldsodefs.h
|
|
|
29e444 |
new file mode 100644
|
|
|
29e444 |
index 0000000..fcedf32
|
|
|
29e444 |
--- /dev/null
|
|
|
12745e |
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/ldsodefs.h
|
|
|
29e444 |
@@ -0,0 +1,33 @@
|
|
|
29e444 |
+/* Run-time dynamic linker data structures for loaded ELF shared objects.
|
|
|
29e444 |
+ PowerPC version.
|
|
|
29e444 |
+ Copyright (C) 2013 Free Software Foundation, Inc.
|
|
|
29e444 |
+ This file is part of the GNU C Library.
|
|
|
29e444 |
+
|
|
|
29e444 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
29e444 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
29e444 |
+ License as published by the Free Software Foundation; either
|
|
|
29e444 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
29e444 |
+
|
|
|
29e444 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
29e444 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
29e444 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
29e444 |
+ Lesser General Public License for more details.
|
|
|
29e444 |
+
|
|
|
29e444 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
29e444 |
+ License along with the GNU C Library; if not, see
|
|
|
29e444 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
29e444 |
+
|
|
|
29e444 |
+#ifndef _LDSODEFS_H
|
|
|
29e444 |
+
|
|
|
29e444 |
+/* Get the real definitions. */
|
|
|
29e444 |
+#include_next <ldsodefs.h>
|
|
|
29e444 |
+
|
|
|
29e444 |
+/* Now define our stuff. */
|
|
|
29e444 |
+
|
|
|
29e444 |
+/* We need special support to initialize DSO loaded for statically linked
|
|
|
29e444 |
+ binaries. */
|
|
|
29e444 |
+extern void _dl_static_init (struct link_map *map);
|
|
|
29e444 |
+#undef DL_STATIC_INIT
|
|
|
29e444 |
+#define DL_STATIC_INIT(map) _dl_static_init (map)
|
|
|
29e444 |
+
|
|
|
29e444 |
+#endif /* ldsodefs.h */
|
|
|
29e444 |
--
|
|
|
29e444 |
1.7.11.7
|
|
|
29e444 |
|