]> git.pld-linux.org Git - packages/glibc.git/blame - glibc-static-glro-init.patch
- fix for mprotect enforced kernel
[packages/glibc.git] / glibc-static-glro-init.patch
CommitLineData
f69cae76
JR
12010-08-18 Mike Frysinger <vapier@gentoo.org>
2
3 * sysdeps/unix/sysv/linux/ia64/Makefile: Move dl-static addition to
4 sysdep vars for subdir==elf to ...
5 * sysdeps/unix/sysv/linux/Makefile: ... here.
6 * sysdeps/unix/sysv/linux/ia64/dl-static.c: Move file to ...
7 * sysdeps/unix/sysv/linux/dl-static.c: ... here.
8 * sysdeps/unix/sysv/linux/ia64/ldsodefs.h: Delete, and move the
9 DL_STATIC_INIT defines to ...
10 * sysdeps/unix/sysv/linux/ldsodefs.h: ... here.
11 * sysdeps/unix/sysv/linux/ia64/getpagesize.c: Delete.
12
13diff --git a/sysdeps/unix/sysv/linux/ia64/Makefile b/sysdeps/unix/sysv/linux/ia64/Makefile
14index d9a35a7..3bb1ce0 100644
15--- a/sysdeps/unix/sysv/linux/ia64/Makefile
16+++ b/sysdeps/unix/sysv/linux/ia64/Makefile
17@@ -12,12 +12,6 @@ sysdep_headers += sys/io.h
18 sysdep_routines += ioperm clone2
19 endif
20
21-ifeq ($(subdir),elf)
22-sysdep-dl-routines += dl-static
23-sysdep_routines += $(sysdep-dl-routines)
24-sysdep-rtld-routines += $(sysdep-dl-routines)
25-endif
26-
27 ifeq ($(subdir),rt)
28 librt-routines += rt-sysdep
29 endif
30diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
31index 4302bd3..37c56a3 100644
32--- a/sysdeps/unix/sysv/linux/Makefile
33+++ b/sysdeps/unix/sysv/linux/Makefile
34@@ -147,7 +147,9 @@ sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
35 endif
36
37 ifeq ($(subdir),elf)
38-sysdep-rtld-routines += dl-brk dl-sbrk
39+sysdep-dl-routines += dl-static
40+sysdep_routines += dl-static
41+sysdep-rtld-routines += dl-brk dl-sbrk dl-static
42
43 CPPFLAGS-lddlibc4 += -DNOT_IN_libc
44 endif
45diff --git a/sysdeps/unix/sysv/linux/ia64/dl-static.c b/sysdeps/unix/sysv/linux/ia64/dl-static.c
46deleted file mode 100644
47index 4efc077..0000000
48--- a/sysdeps/unix/sysv/linux/ia64/dl-static.c
49+++ /dev/null
50@@ -1,69 +0,0 @@
51-/* Variable initialization. IA-64 version.
52- Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
53- This file is part of the GNU C Library.
54-
55- The GNU C Library is free software; you can redistribute it and/or
56- modify it under the terms of the GNU Lesser General Public
57- License as published by the Free Software Foundation; either
58- version 2.1 of the License, or (at your option) any later version.
59-
60- The GNU C Library is distributed in the hope that it will be useful,
61- but WITHOUT ANY WARRANTY; without even the implied warranty of
62- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
63- Lesser General Public License for more details.
64-
65- You should have received a copy of the GNU Lesser General Public
66- License along with the GNU C Library; if not, write to the Free
67- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
68- 02111-1307 USA. */
69-
70-#include <ldsodefs.h>
71-
72-#ifdef SHARED
73-
74-void
75-_dl_var_init (void *array[])
76-{
77- /* It has to match "variables" below. */
78- enum
79- {
80- DL_PAGESIZE = 0,
81- DL_CLKTCK
82- };
83-
84- GLRO(dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
85- GLRO(dl_clktck) = *((int *) array[DL_CLKTCK]);
86-}
87-
88-#else
89-#include <bits/libc-lock.h>
90-
91-__libc_lock_define_initialized_recursive (static, _dl_static_lock)
92-
93-static void *variables[] =
94-{
95- &GLRO(dl_pagesize),
96- &GLRO(dl_clktck)
97-};
98-
99-void
100-_dl_static_init (struct link_map *map)
101-{
102- const ElfW(Sym) *ref = NULL;
103- lookup_t loadbase;
104- void (*f) (void *[]);
105-
106- __libc_lock_lock_recursive (_dl_static_lock);
107-
108- loadbase = _dl_lookup_symbol_x ("_dl_var_init", map, &ref,
109- map->l_local_scope, NULL, 0, 1, NULL);
110- if (ref != NULL)
111- {
112- f = (void (*) (void *[])) DL_SYMBOL_ADDRESS (loadbase, ref);
113- f (variables);
114- }
115-
116- __libc_lock_unlock_recursive (_dl_static_lock);
117-}
118-
119-#endif
120diff --git a/sysdeps/unix/sysv/linux/dl-static.c b/sysdeps/unix/sysv/linux/dl-static.c
121new file mode 100644
122index 0000000..fa70811
123--- /dev/null
124+++ b/sysdeps/unix/sysv/linux/dl-static.c
125@@ -0,0 +1,69 @@
126+/* Variable initialization.
127+ Copyright (C) 2001, 2002, 2003, 2004, 2010 Free Software Foundation, Inc.
128+ This file is part of the GNU C Library.
129+
130+ The GNU C Library is free software; you can redistribute it and/or
131+ modify it under the terms of the GNU Lesser General Public
132+ License as published by the Free Software Foundation; either
133+ version 2.1 of the License, or (at your option) any later version.
134+
135+ The GNU C Library is distributed in the hope that it will be useful,
136+ but WITHOUT ANY WARRANTY; without even the implied warranty of
137+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
138+ Lesser General Public License for more details.
139+
140+ You should have received a copy of the GNU Lesser General Public
141+ License along with the GNU C Library; if not, write to the Free
142+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
143+ 02111-1307 USA. */
144+
145+#include <ldsodefs.h>
146+
147+#ifdef SHARED
148+
149+void
150+_dl_var_init (void *array[])
151+{
152+ /* It has to match "variables" below. */
153+ enum
154+ {
155+ DL_PAGESIZE = 0,
156+ DL_CLKTCK
157+ };
158+
159+ GLRO(dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
160+ GLRO(dl_clktck) = *((int *) array[DL_CLKTCK]);
161+}
162+
163+#else
164+#include <bits/libc-lock.h>
165+
166+__libc_lock_define_initialized_recursive (static, _dl_static_lock)
167+
168+static void *variables[] =
169+{
170+ &GLRO(dl_pagesize),
171+ &GLRO(dl_clktck)
172+};
173+
174+void
175+_dl_static_init (struct link_map *map)
176+{
177+ const ElfW(Sym) *ref = NULL;
178+ lookup_t loadbase;
179+ void (*f) (void *[]);
180+
181+ __libc_lock_lock_recursive (_dl_static_lock);
182+
183+ loadbase = _dl_lookup_symbol_x ("_dl_var_init", map, &ref,
184+ map->l_local_scope, NULL, 0, 1, NULL);
185+ if (ref != NULL)
186+ {
187+ f = (void (*) (void *[])) DL_SYMBOL_ADDRESS (loadbase, ref);
188+ f (variables);
189+ }
190+
191+ __libc_lock_unlock_recursive (_dl_static_lock);
192+}
193+
194+#endif
195diff --git a/sysdeps/unix/sysv/linux/ia64/ldsodefs.h b/sysdeps/unix/sysv/linux/ia64/ldsodefs.h
196deleted file mode 100644
197index 31af624..0000000
198--- a/sysdeps/unix/sysv/linux/ia64/ldsodefs.h
199+++ /dev/null
200@@ -1,33 +0,0 @@
201-/* Run-time dynamic linker data structures for loaded ELF shared objects. IA64.
202- Copyright (C) 2001 Free Software Foundation, Inc.
203- This file is part of the GNU C Library.
204-
205- The GNU C Library is free software; you can redistribute it and/or
206- modify it under the terms of the GNU Lesser General Public
207- License as published by the Free Software Foundation; either
208- version 2.1 of the License, or (at your option) any later version.
209-
210- The GNU C Library is distributed in the hope that it will be useful,
211- but WITHOUT ANY WARRANTY; without even the implied warranty of
212- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
213- Lesser General Public License for more details.
214-
215- You should have received a copy of the GNU Lesser General Public
216- License along with the GNU C Library; if not, write to the Free
217- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
218- 02111-1307 USA. */
219-
220-#ifndef _LDSODEFS_H
221-
222-/* Get the real definitions. */
223-#include_next <ldsodefs.h>
224-
225-/* Now define our stuff. */
226-
227-/* We need special support to initialize DSO loaded for statically linked
228- binaries. */
229-extern void _dl_static_init (struct link_map *map);
230-#undef DL_STATIC_INIT
231-#define DL_STATIC_INIT(map) _dl_static_init (map)
232-
233-#endif /* ldsodefs.h */
234diff --git a/sysdeps/unix/sysv/linux/ldsodefs.h b/sysdeps/unix/sysv/linux/ldsodefs.h
235index 5d5b1b4..ecb5d4f 100644
236--- a/sysdeps/unix/sysv/linux/ldsodefs.h
237+++ b/sysdeps/unix/sysv/linux/ldsodefs.h
238@@ -36,6 +36,12 @@ extern void _dl_aux_init (ElfW(auxv_t) *av) internal_function;
239 /* Initialization which is normally done by the dynamic linker. */
240 extern void _dl_non_dynamic_init (void) internal_function;
241
242+/* We need special support to initialize DSO loaded for statically linked
243+ binaries. */
244+extern void _dl_static_init (struct link_map *map);
245+#undef DL_STATIC_INIT
246+#define DL_STATIC_INIT(map) _dl_static_init (map)
247+
248 /* We can assume that the kernel always provides the AT_UID, AT_EUID,
249 AT_GID, and AT_EGID values in the auxiliary vector from 2.4.0 or so on. */
250 #if __ASSUME_AT_XID
251diff --git a/sysdeps/unix/sysv/linux/ia64/getpagesize.c b/sysdeps/unix/sysv/linux/ia64/getpagesize.c
252deleted file mode 100644
253index 1155dfd..0000000
254--- a/sysdeps/unix/sysv/linux/ia64/getpagesize.c
255+++ /dev/null
256@@ -1,39 +0,0 @@
257-/* Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
258- This file is part of the GNU C Library.
259-
260- The GNU C Library is free software; you can redistribute it and/or
261- modify it under the terms of the GNU Lesser General Public
262- License as published by the Free Software Foundation; either
263- version 2.1 of the License, or (at your option) any later version.
264-
265- The GNU C Library is distributed in the hope that it will be useful,
266- but WITHOUT ANY WARRANTY; without even the implied warranty of
267- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
268- Lesser General Public License for more details.
269-
270- You should have received a copy of the GNU Lesser General Public
271- License along with the GNU C Library; if not, write to the Free
272- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
273- 02111-1307 USA. */
274-
275-#include <assert.h>
276-#include <unistd.h>
277-#include <sys/param.h>
278-
279-#include <ldsodefs.h>
280-#include <sysdep.h>
281-#include <sys/syscall.h>
282-
283-/* Return the system page size. The return value will depend on how
284- the kernel is configured. A program must use this call to
285- determine the page size to ensure proper alignment for calls such
286- as mmap and friends. --davidm 99/11/30 */
287-
288-int
289-__getpagesize ()
290-{
291- assert (GLRO(dl_pagesize) != 0);
292- return GLRO(dl_pagesize);
293-}
294-libc_hidden_def (__getpagesize)
295-weak_alias (__getpagesize, getpagesize)
This page took 0.059086 seconds and 4 git commands to generate.