]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/glibc/glibc-rh711927.patch
Merge remote-tracking branch 'origin/next' into thirteen
[people/pmueller/ipfire-2.x.git] / src / patches / glibc / glibc-rh711927.patch
1 Index: glibc-2.12-2-gc4ccff1/config.h.in
2 ===================================================================
3 --- glibc-2.12-2-gc4ccff1.orig/config.h.in
4 +++ glibc-2.12-2-gc4ccff1/config.h.in
5 @@ -201,6 +201,9 @@
6 /* Define if multi-arch DSOs should be generated. */
7 #undef USE_MULTIARCH
8
9 +/* Define if Systemtap <sys/sdt.h> probes should be defined. */
10 +#undef USE_STAP_PROBE
11 +
12 /*
13 \f */
14
15 Index: glibc-2.12-2-gc4ccff1/configure
16 ===================================================================
17 --- glibc-2.12-2-gc4ccff1.orig/configure
18 +++ glibc-2.12-2-gc4ccff1/configure
19 @@ -830,6 +830,7 @@ enable_all_warnings
20 enable_multi_arch
21 enable_experimental_malloc
22 enable_nss_crypt
23 +enable_systemtap
24 with_cpu
25 '
26 ac_precious_vars='build_alias
27 @@ -1501,6 +1502,7 @@ Optional Features:
28 --enable-experimental-malloc
29 enable experimental malloc features
30 --enable-nss-crypt enable libcrypt to use nss
31 + --enable-systemtap enable systemtap static probe points [default=no]
32
33 Optional Packages:
34 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
35 @@ -3932,6 +3934,79 @@ else
36 fi
37
38
39 +# Check whether --enable-systemtap was given.
40 +if test "${enable_systemtap+set}" = set; then
41 + enableval=$enable_systemtap; systemtap=$enableval
42 +else
43 + systemtap=no
44 +fi
45 +
46 +if test x$systemtap != xno; then
47 +
48 + { $as_echo "$as_me:$LINENO: checking for systemtap static probe support" >&5
49 +$as_echo_n "checking for systemtap static probe support... " >&6; }
50 +if test "${libc_cv_sdt+set}" = set; then
51 + $as_echo_n "(cached) " >&6
52 +else
53 + old_CFLAGS="$CFLAGS"
54 + CFLAGS="-std=gnu99 $CFLAGS"
55 + cat >conftest.$ac_ext <<_ACEOF
56 +#include <sys/sdt.h>
57 +void foo (int i, void *p)
58 +{
59 + asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
60 + :: STAP_PROBE_ASM_OPERANDS (2, i, p));
61 +}
62 +_ACEOF
63 +rm -f conftest.$ac_objext
64 +if { (ac_try="$ac_compile"
65 +case "(($ac_try" in
66 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
67 + *) ac_try_echo=$ac_try;;
68 +esac
69 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
70 +$as_echo "$ac_try_echo") >&5
71 + (eval "$ac_compile") 2>conftest.er1
72 + ac_status=$?
73 + grep -v '^ *+' conftest.er1 >conftest.err
74 + rm -f conftest.er1
75 + cat conftest.err >&5
76 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
77 + (exit $ac_status); } && {
78 + test -z "$ac_c_werror_flag" ||
79 + test ! -s conftest.err
80 + } && test -s conftest.$ac_objext; then
81 + libc_cv_sdt=yes
82 +else
83 + $as_echo "$as_me: failed program was:" >&5
84 +sed 's/^/| /' conftest.$ac_ext >&5
85 +
86 + libc_cv_sdt=no
87 +fi
88 +
89 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
90 + CFLAGS="$old_CFLAGS"
91 +fi
92 +{ $as_echo "$as_me:$LINENO: result: $libc_cv_sdt" >&5
93 +$as_echo "$libc_cv_sdt" >&6; }
94 + if test $libc_cv_sdt = yes; then
95 + cat >>confdefs.h <<\_ACEOF
96 +#define USE_STAP_PROBE 1
97 +_ACEOF
98 +
99 + else
100 + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
101 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
102 +{ { $as_echo "$as_me:$LINENO: error: systemtap support needs sys/sdt.h with asm support
103 +See \`config.log' for more details." >&5
104 +$as_echo "$as_me: error: systemtap support needs sys/sdt.h with asm support
105 +See \`config.log' for more details." >&2;}
106 + { (exit 1); exit 1; }; }; }
107 + fi
108 +
109 +fi
110 +
111 +
112 # The way shlib-versions is used to generate soversions.mk uses a
113 # fairly simplistic model for name recognition that can't distinguish
114 # i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a $host_os
115 Index: glibc-2.12-2-gc4ccff1/configure.in
116 ===================================================================
117 --- glibc-2.12-2-gc4ccff1.orig/configure.in
118 +++ glibc-2.12-2-gc4ccff1/configure.in
119 @@ -319,6 +319,29 @@ else
120 fi
121 AC_SUBST(libc_cv_nss_crypt)
122
123 +AC_ARG_ENABLE([systemtap],
124 + [AS_HELP_STRING([--enable-systemtap],
125 + [enable systemtap static probe points @<:@default=no@:>@])],
126 + [systemtap=$enableval],
127 + [systemtap=no])
128 +AS_IF([test x$systemtap != xno], [
129 + AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
130 + old_CFLAGS="$CFLAGS"
131 + CFLAGS="-std=gnu99 $CFLAGS"
132 + AC_COMPILE_IFELSE([#include <sys/sdt.h>
133 +void foo (int i, void *p)
134 +{
135 + asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
136 + :: STAP_PROBE_ASM_OPERANDS (2, i, p));
137 +}], [libc_cv_sdt=yes], [libc_cv_sdt=no])
138 + CFLAGS="$old_CFLAGS"])
139 + if test $libc_cv_sdt = yes; then
140 + AC_DEFINE([USE_STAP_PROBE])
141 + else
142 + AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
143 + fi
144 +])
145 +
146 # The way shlib-versions is used to generate soversions.mk uses a
147 # fairly simplistic model for name recognition that can't distinguish
148 # i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a $host_os
149 Index: glibc-2.12-2-gc4ccff1/elf/Makefile
150 ===================================================================
151 --- glibc-2.12-2-gc4ccff1.orig/elf/Makefile
152 +++ glibc-2.12-2-gc4ccff1/elf/Makefile
153 @@ -458,7 +458,8 @@ CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'
154 CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
155 CFLAGS-cache.c = $(SYSCONF-FLAGS)
156
157 -CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),-DNOT_IN_libc=1 -DIS_IN_rtld=1)
158 +CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
159 + -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld)
160
161 test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
162 generated += $(addsuffix .so,$(strip $(modules-names)))
163 Index: glibc-2.12-2-gc4ccff1/elf/dl-close.c
164 ===================================================================
165 --- glibc-2.12-2-gc4ccff1.orig/elf/dl-close.c
166 +++ glibc-2.12-2-gc4ccff1/elf/dl-close.c
167 @@ -32,6 +32,7 @@
168 #include <sys/mman.h>
169 #include <sysdep-cancel.h>
170 #include <tls.h>
171 +#include <stap-probe.h>
172
173
174 /* Type of the constructor functions. */
175 @@ -469,6 +470,7 @@ _dl_close_worker (struct link_map *map)
176 struct r_debug *r = _dl_debug_initialize (0, nsid);
177 r->r_state = RT_DELETE;
178 _dl_debug_state ();
179 + LIBC_PROBE (rtld_unmap_start, 2, nsid, r);
180
181 if (unload_global)
182 {
183 @@ -722,6 +724,7 @@ _dl_close_worker (struct link_map *map)
184 /* Notify the debugger those objects are finalized and gone. */
185 r->r_state = RT_CONSISTENT;
186 _dl_debug_state ();
187 + LIBC_PROBE (rtld_unmap_complete, 2, nsid, r);
188
189 /* Recheck if we need to retry, release the lock. */
190 out:
191 Index: glibc-2.12-2-gc4ccff1/elf/dl-load.c
192 ===================================================================
193 --- glibc-2.12-2-gc4ccff1.orig/elf/dl-load.c
194 +++ glibc-2.12-2-gc4ccff1/elf/dl-load.c
195 @@ -36,6 +36,7 @@
196 #include <stackinfo.h>
197 #include <caller.h>
198 #include <sysdep.h>
199 +#include <stap-probe.h>
200
201 #include <dl-dst.h>
202
203 @@ -806,7 +807,7 @@ _dl_init_paths (const char *llp)
204 static void
205 __attribute__ ((noreturn, noinline))
206 lose (int code, int fd, const char *name, char *realname, struct link_map *l,
207 - const char *msg, struct r_debug *r)
208 + const char *msg, struct r_debug *r, Lmid_t nsid)
209 {
210 /* The file might already be closed. */
211 if (fd != -1)
212 @@ -818,6 +819,7 @@ lose (int code, int fd, const char *name
213 {
214 r->r_state = RT_CONSISTENT;
215 _dl_debug_state ();
216 + LIBC_PROBE (rtld_map_complete, 2, nsid, r);
217 }
218
219 _dl_signal_error (code, name, NULL, msg);
220 @@ -856,7 +858,7 @@ _dl_map_object_from_fd (const char *name
221 errval = errno;
222 call_lose:
223 lose (errval, fd, name, realname, l, errstring,
224 - make_consistent ? r : NULL);
225 + make_consistent ? r : NULL, nsid);
226 }
227
228 /* Look again to see if the real name matched another already loaded. */
229 @@ -963,6 +965,7 @@ _dl_map_object_from_fd (const char *name
230 linking has not been used before. */
231 r->r_state = RT_ADD;
232 _dl_debug_state ();
233 + LIBC_PROBE (rtld_map_start, 2, nsid, r);
234 make_consistent = true;
235 }
236 else
237 @@ -1656,7 +1659,7 @@ open_verify (const char *name, struct fi
238 name = strdupa (realname);
239 free (realname);
240 }
241 - lose (errval, fd, name, NULL, NULL, errstring, NULL);
242 + lose (errval, fd, name, NULL, NULL, errstring, NULL, 0);
243 }
244
245 /* See whether the ELF header is what we expect. */
246 Index: glibc-2.12-2-gc4ccff1/elf/dl-open.c
247 ===================================================================
248 --- glibc-2.12-2-gc4ccff1.orig/elf/dl-open.c
249 +++ glibc-2.12-2-gc4ccff1/elf/dl-open.c
250 @@ -33,6 +33,7 @@
251 #include <caller.h>
252 #include <sysdep-cancel.h>
253 #include <tls.h>
254 +#include <stap-probe.h>
255
256 #include <dl-dst.h>
257
258 @@ -297,6 +298,7 @@ dl_open_worker (void *a)
259 struct r_debug *r = _dl_debug_initialize (0, args->nsid);
260 r->r_state = RT_CONSISTENT;
261 _dl_debug_state ();
262 + LIBC_PROBE (rtld_map_complete, 2, args->nsid, r);
263
264 /* Only do lazy relocation if `LD_BIND_NOW' is not set. */
265 int reloc_mode = mode & __RTLD_AUDIT;
266 @@ -309,10 +311,18 @@ dl_open_worker (void *a)
267 struct link_map *l = new;
268 while (l->l_next)
269 l = l->l_next;
270 + int relocation_in_progress = 0;
271 while (1)
272 {
273 if (! l->l_real->l_relocated)
274 {
275 + if (! relocation_in_progress)
276 + {
277 + /* Notify the debugger that relocations are about to happen. */
278 + LIBC_PROBE (rtld_reloc_start, 2, args->nsid, r);
279 + relocation_in_progress = 1;
280 + }
281 +
282 #ifdef SHARED
283 if (__builtin_expect (GLRO(dl_profile) != NULL, 0))
284 {
285 @@ -460,6 +470,10 @@ cannot load any more object with static
286 _dl_fatal_printf (N_("\
287 TLS generation counter wrapped! Please report this."));
288
289 + /* Notify the debugger all new objects have been relocated. */
290 + if (relocation_in_progress)
291 + LIBC_PROBE (rtld_reloc_complete, 2, args->nsid, r);
292 +
293 /* Run the initializer functions of new objects. */
294 _dl_init (new, args->argc, args->argv, args->env);
295
296 Index: glibc-2.12-2-gc4ccff1/elf/rtld-Rules
297 ===================================================================
298 --- glibc-2.12-2-gc4ccff1.orig/elf/rtld-Rules
299 +++ glibc-2.12-2-gc4ccff1/elf/rtld-Rules
300 @@ -122,6 +122,6 @@ ifdef rtld-depfiles
301 endif
302
303 # This here is the whole point of all the shenanigans.
304 -rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1
305 +rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld
306
307 endif
308 Index: glibc-2.12-2-gc4ccff1/elf/rtld.c
309 ===================================================================
310 --- glibc-2.12-2-gc4ccff1.orig/elf/rtld.c
311 +++ glibc-2.12-2-gc4ccff1/elf/rtld.c
312 @@ -40,6 +40,7 @@
313 #include <dl-osinfo.h>
314 #include <dl-procinfo.h>
315 #include <tls.h>
316 +#include <stap-probe.h>
317
318 #include <assert.h>
319
320 @@ -1656,6 +1657,7 @@ ERROR: ld.so: object '%s' cannot be load
321 /* We start adding objects. */
322 r->r_state = RT_ADD;
323 _dl_debug_state ();
324 + LIBC_PROBE (rtld_init_start, 2, LM_ID_BASE, r);
325
326 /* Auditing checkpoint: we are ready to signal that the initial map
327 is being constructed. */
328 @@ -2353,6 +2355,7 @@ ERROR: ld.so: object '%s' cannot be load
329 r = _dl_debug_initialize (0, LM_ID_BASE);
330 r->r_state = RT_CONSISTENT;
331 _dl_debug_state ();
332 + LIBC_PROBE (rtld_init_complete, 2, LM_ID_BASE, r);
333
334 #ifndef MAP_COPY
335 /* We must munmap() the cache file. */
336 Index: glibc-2.12-2-gc4ccff1/extra-lib.mk
337 ===================================================================
338 --- glibc-2.12-2-gc4ccff1.orig/extra-lib.mk
339 +++ glibc-2.12-2-gc4ccff1/extra-lib.mk
340 @@ -101,4 +101,4 @@ ifneq (,$(cpp-srcs-left))
341 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
342 endif
343
344 -CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1
345 +CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1 -DIN_LIB=$(lib)
346 Index: glibc-2.12-2-gc4ccff1/include/stap-probe.h
347 ===================================================================
348 --- /dev/null
349 +++ glibc-2.12-2-gc4ccff1/include/stap-probe.h
350 @@ -0,0 +1,140 @@
351 +/* Macros for defining Systemtap <sys/sdt.h> static probe points.
352 + Copyright (C) 2011 Free Software Foundation, Inc.
353 + This file is part of the GNU C Library.
354 +
355 + The GNU C Library is free software; you can redistribute it and/or
356 + modify it under the terms of the GNU Lesser General Public
357 + License as published by the Free Software Foundation; either
358 + version 2.1 of the License, or (at your option) any later version.
359 +
360 + The GNU C Library is distributed in the hope that it will be useful,
361 + but WITHOUT ANY WARRANTY; without even the implied warranty of
362 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
363 + Lesser General Public License for more details.
364 +
365 + You should have received a copy of the GNU Lesser General Public
366 + License along with the GNU C Library; if not, write to the Free
367 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
368 + 02111-1307 USA. */
369 +
370 +#ifndef _STAP_PROBE_H
371 +#define _STAP_PROBE_H 1
372 +
373 +#ifdef USE_STAP_PROBE
374 +
375 +# include <sys/sdt.h>
376 +
377 +/* Our code uses one macro LIBC_PROBE (name, n, arg1, ..., argn).
378 +
379 + Without USE_STAP_PROBE, that does nothing but evaluates all
380 + its arguments (to prevent bit rot, unlike e.g. assert).
381 +
382 + Systemtap's header defines the macros STAP_PROBE (provider, name) and
383 + STAP_PROBEn (provider, name, arg1, ..., argn). For "provider" we paste
384 + in the IN_LIB name (libc, libpthread, etc.) automagically. */
385 +
386 +# ifndef NOT_IN_libc
387 +# define IN_LIB libc
388 +# elif !defined IN_LIB
389 +/* This is intentionally defined with extra unquoted commas in it so
390 + that macro substitution will bomb out when it is used. We don't
391 + just use #error here, so that this header can be included by
392 + other headers that use LIBC_PROBE inside their own macros. We
393 + only want such headers to fail to compile if those macros are
394 + actually used in a context where IN_LIB has not been defined. */
395 +# define IN_LIB ,,,missing -DIN_LIB=... -- not extra-lib.mk?,,,
396 +# endif
397 +
398 +# define LIBC_PROBE(name, n, ...) \
399 + LIBC_PROBE_1 (IN_LIB, name, n, ## __VA_ARGS__)
400 +
401 +# define LIBC_PROBE_1(lib, name, n, ...) \
402 + STAP_PROBE##n (lib, name, ## __VA_ARGS__)
403 +
404 +# define STAP_PROBE0 STAP_PROBE
405 +
406 +# define LIBC_PROBE_ASM(name, template) \
407 + STAP_PROBE_ASM (IN_LIB, name, template)
408 +
409 +# define LIBC_PROBE_ASM_OPERANDS STAP_PROBE_ASM_OPERANDS
410 +
411 +#else /* Not USE_STAP_PROBE. */
412 +
413 +# ifndef __ASSEMBLER__
414 +# define LIBC_PROBE(name, n, ...) DUMMY_PROBE##n (__VA_ARGS__)
415 +# else
416 +# define LIBC_PROBE(name, n, ...) /* Nothing. */
417 +# endif
418 +
419 +# define LIBC_PROBE_ASM(name, template) /* Nothing. */
420 +# define LIBC_PROBE_ASM_OPERANDS(n, ...) /* Nothing. */
421 +
422 +/* This silliness lets us evaluate all the arguments for each arity
423 + of probe. My kingdom for a real macro system. */
424 +
425 +# define DUMMY_PROBE0() do {} while (0)
426 +# define DUMMY_PROBE1(a1) do {} while ((void) (a1), 0)
427 +# define DUMMY_PROBE2(a1, a2) do {} while ((void) (a1), \
428 + (void) (a2), 0)
429 +# define DUMMY_PROBE3(a1, a2, a3) do {} while ((void) (a1), \
430 + (void) (a2), \
431 + (void) (a3), 0)
432 +# define DUMMY_PROBE4(a1, a2, a3, a4) do {} while ((void) (a1), \
433 + (void) (a2), \
434 + (void) (a3), \
435 + (void) (a4), 0)
436 +# define DUMMY_PROBE5(a1, a2, a3, a4, a5) \
437 + do {} while ((void) (a1), \
438 + (void) (a2), \
439 + (void) (a3), \
440 + (void) (a4), \
441 + (void) (a5), 0)
442 +# define DUMMY_PROBE6(a1, a2, a3, a4, a5, a6) \
443 + do {} while ((void) (a1), \
444 + (void) (a2), \
445 + (void) (a3), \
446 + (void) (a4), \
447 + (void) (a5), \
448 + (void) (a6), 0)
449 +# define DUMMY_PROBE7(a1, a2, a3, a4, a5, a6, a7) \
450 + do {} while ((void) (a1), \
451 + (void) (a2), \
452 + (void) (a3), \
453 + (void) (a4), \
454 + (void) (a5), \
455 + (void) (a6), \
456 + (void) (a7), 0)
457 +# define DUMMY_PROBE8(a1, a2, a3, a4, a5, a6, a7, a8) \
458 + do {} while ((void) (a1), \
459 + (void) (a2), \
460 + (void) (a3), \
461 + (void) (a4), \
462 + (void) (a5), \
463 + (void) (a6), \
464 + (void) (a7), \
465 + (void) (a8), 0)
466 +# define DUMMY_PROBE9(a1, a2, a3, a4, a5, a6, a7, a8, a9) \
467 + do {} while ((void) (a1), \
468 + (void) (a2), \
469 + (void) (a3), \
470 + (void) (a4), \
471 + (void) (a5), \
472 + (void) (a6), \
473 + (void) (a7), \
474 + (void) (a8), \
475 + (void) (a9), 0)
476 +# define DUMMY_PROBE10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \
477 + do {} while ((void) (a1), \
478 + (void) (a2), \
479 + (void) (a3), \
480 + (void) (a4), \
481 + (void) (a5), \
482 + (void) (a6), \
483 + (void) (a7), \
484 + (void) (a8), \
485 + (void) (a9), \
486 + (void) (a10), 0)
487 +
488 +#endif /* USE_STAP_PROBE. */
489 +
490 +#endif /* stap-probe.h */
491 Index: glibc-2.12-2-gc4ccff1/scripts/check-local-headers.sh
492 ===================================================================
493 --- glibc-2.12-2-gc4ccff1.orig/scripts/check-local-headers.sh
494 +++ glibc-2.12-2-gc4ccff1/scripts/check-local-headers.sh
495 @@ -31,6 +31,8 @@ fgrep -v "$includedir/asm" |
496 fgrep -v "$includedir/linux" |
497 fgrep -v "$includedir/selinux" |
498 fgrep -v "$includedir/sys/capability.h" |
499 +fgrep -v "$includedir/sys/sdt.h" |
500 +fgrep -v "$includedir/sys/sdt-config.h" |
501 fgrep -v "$includedir/gd" |
502 fgrep -v "$includedir/nss3"; then
503 # If we found a match something is wrong.