]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/glibc/glibc-rh1032628.patch
pakfire: use correct tree on x86_64.
[ipfire-2.x.git] / src / patches / glibc / glibc-rh1032628.patch
CommitLineData
fe875de8
MT
1commit 028478fa40d85a73b19638dbe3f83b1acebf370c
2Author: Ulrich Drepper <drepper@gmail.com>
3Date: Thu Mar 10 12:51:33 2011 -0500
4
5 Fix copy relocations handling of unique objects.
6
7 2011-03-06 Ulrich Drepper <drepper@gmail.com>
8
9and a part of:
10
11commit 33f85a3fb9fe432e0ebf6a3481bc2d5e29cb605f
12Author: Ulrich Drepper <drepper@gmail.com>
13Date: Thu Mar 10 03:18:21 2011 -0500
14
15 Don't run tests checking xecutable stack when SELinux is enforcing.
16
17since the latter incorrectly had a bit of the former changes.
18
19Additionally, the test case needs -lstdc++ to build.
20
21diff --git a/elf/Makefile b/elf/Makefile
22index c427679..56cb1b1 100644
23--- a/elf/Makefile
24+++ b/elf/Makefile
25@@ -201,7 +201,7 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
26 unload3 unload4 unload5 unload6 unload7 unload8 tst-global1 order2 \
27 tst-audit1 tst-audit2 tst-audit9 \
28 tst-stackguard1 tst-addr1 tst-thrlock \
29- tst-unique1 tst-unique2
30+ tst-unique1 tst-unique2 tst-unique3
31 # reldep9
32 test-srcs = tst-pathopt
33 tests-execstack-yes = tst-execstack tst-execstack-needed tst-execstack-prog
34@@ -255,6 +255,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
35 order2mod1 order2mod2 order2mod3 order2mod4 \
36 tst-unique1mod1 tst-unique1mod2 \
37 tst-unique2mod1 tst-unique2mod2 \
38+ tst-unique3lib tst-unique3lib2 \
39 tst-auditmod9a tst-auditmod9b
40 ifeq (yes,$(have-initfini-array))
41 modules-names += tst-array2dep tst-array5dep
42@@ -1178,6 +1179,11 @@ $(objpfx)tst-unique1.out: $(objpfx)tst-unique1mod1.so \
43 $(objpfx)tst-unique2: $(libdl) $(objpfx)tst-unique2mod1.so
44 $(objpfx)tst-unique2.out: $(objpfx)tst-unique2mod2.so
45
46+LDLIBS-tst-unique3lib.so = -lstdc++
47+LDLIBS-tst-unique3lib2.so = -lstdc++
48+$(objpfx)tst-unique3: $(libdl) $(objpfx)tst-unique3lib.so
49+$(objpfx)tst-unique3.out: $(objpfx)tst-unique3lib2.so
50+
51 ifeq (yes,$(config-cflags-avx))
52 CFLAGS-tst-audit4.c += -mavx
53 CFLAGS-tst-auditmod4a.c += -mavx
54diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
55index 78c8669..874a4bb 100644
56--- a/elf/dl-lookup.c
57+++ b/elf/dl-lookup.c
58@@ -364,8 +363,19 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
59 if (entries[idx].hashval == new_hash
60 && strcmp (entries[idx].name, undef_name) == 0)
61 {
62- result->s = entries[idx].sym;
63- result->m = (struct link_map *) entries[idx].map;
64+ if ((type_class & ELF_RTYPE_CLASS_COPY) != 0)
65+ {
66+ /* We possibly have to initialize the central
67+ copy from the copy addressed through the
68+ relocation. */
69+ result->s = sym;
70+ result->m = (struct link_map *) map;
71+ }
72+ else
73+ {
74+ result->s = entries[idx].sym;
75+ result->m = (struct link_map *) entries[idx].map;
76+ }
77 __rtld_lock_unlock_recursive (tab->lock);
78 return 1;
79 }
80diff --git a/elf/tst-unique3.cc b/elf/tst-unique3.cc
81new file mode 100644
82index 0000000..b2c9593
83--- /dev/null
84+++ b/elf/tst-unique3.cc
85@@ -0,0 +1,23 @@
86+#include "tst-unique3.h"
87+#include <cstdio>
88+#include "../dlfcn/dlfcn.h"
89+
90+int t = S<char>::i;
91+
92+int
93+main (void)
94+{
95+ std::printf ("%d %d\n", S<char>::i, t);
96+ int result = S<char>::i++ != 1 || t != 1;
97+ result |= in_lib ();
98+ void *d = dlopen ("$ORIGIN/tst-unique3lib2.so", RTLD_LAZY);
99+ int (*fp) ();
100+ if (d == NULL || (fp = (int(*)()) dlsym (d, "in_lib2")) == NULL)
101+ {
102+ std::printf ("failed to get symbol in_lib2\n");
103+ return 1;
104+ }
105+ result |= fp ();
106+ dlclose (d);
107+ return result;
108+}
109diff --git a/elf/tst-unique3.h b/elf/tst-unique3.h
110new file mode 100644
111index 0000000..716d236
112--- /dev/null
113+++ b/elf/tst-unique3.h
114@@ -0,0 +1,8 @@
115+// BZ 12510
116+template<typename T>
117+struct S
118+{
119+ static int i;
120+};
121+
122+extern int in_lib (void);
123diff --git a/elf/tst-unique3lib.cc b/elf/tst-unique3lib.cc
124new file mode 100644
125index 0000000..fa8e85a
126--- /dev/null
127+++ b/elf/tst-unique3lib.cc
128@@ -0,0 +1,11 @@
129+#include <cstdio>
130+#include "tst-unique3.h"
131+template<typename T> int S<T>::i = 1;
132+static int i = S<char>::i;
133+
134+int
135+in_lib (void)
136+{
137+ std::printf ("in_lib: %d %d\n", S<char>::i, i);
138+ return S<char>::i++ != 2 || i != 1;
139+}
140diff --git a/elf/tst-unique3lib2.cc b/elf/tst-unique3lib2.cc
141new file mode 100644
142index 0000000..17d817e
143--- /dev/null
144+++ b/elf/tst-unique3lib2.cc
145@@ -0,0 +1,12 @@
146+#include <cstdio>
147+#include "tst-unique3.h"
148+
149+template<typename T> int S<T>::i;
150+
151+extern "C"
152+int
153+in_lib2 ()
154+{
155+ std::printf ("in_lib2: %d\n", S<char>::i);
156+ return S<char>::i != 3;
157+}
158diff --git a/include/bits/dlfcn.h b/include/bits/dlfcn.h
159index cb4a5c2..c31a645 100644
160--- a/include/bits/dlfcn.h
161+++ b/include/bits/dlfcn.h
162@@ -1,4 +1,3 @@
163 #include_next <bits/dlfcn.h>
164
165-extern void _dl_mcount_wrapper_check (void *__selfpc);
166 libc_hidden_proto (_dl_mcount_wrapper_check)