]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/glibc/glibc-rh646954.patch
Merge remote-tracking branch 'origin/next' into thirteen
[people/pmueller/ipfire-2.x.git] / src / patches / glibc / glibc-rh646954.patch
1 2010-10-26 Ulrich Drepper <drepper@gmail.com>
2
3 * elf/rtld.c (dl_main): Move assertion after the point where rtld map
4 is added to the list.
5
6 2010-10-20 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
7 Ulrich Drepper <drepper@gmail.com>
8
9 * elf/dl-object.c (_dl_new_object): Don't append the new object to
10 the global list here. Move code to...
11 (_dl_add_to_namespace_list): ...here. New function.
12 * elf/rtld.c (dl_main): Invoke _dl_add_to_namespace_list.
13 * sysdeps/generic/ldsodefs.h (_dl_add_to_namespace_list): Declare.
14 * elf/dl-load.c (lose): Don't remove the element from the list.
15 (_dl_map_object_from_fd): Invoke _dl_add_to_namespace_list.
16 (_dl_map_object): Likewise.
17
18 Index: glibc-2.12-2-gc4ccff1/elf/dl-load.c
19 ===================================================================
20 --- glibc-2.12-2-gc4ccff1.orig/elf/dl-load.c
21 +++ glibc-2.12-2-gc4ccff1/elf/dl-load.c
22 @@ -797,22 +797,7 @@ lose (int code, int fd, const char *name
23 /* The file might already be closed. */
24 if (fd != -1)
25 (void) __close (fd);
26 - if (l != NULL)
27 - {
28 - /* We modify the list of loaded objects. */
29 - __rtld_lock_lock_recursive (GL(dl_load_write_lock));
30 - /* Remove the stillborn object from the list and free it. */
31 - assert (l->l_next == NULL);
32 - if (l->l_prev == NULL)
33 - /* No other module loaded. This happens only in the static library,
34 - or in rtld under --verify. */
35 - GL(dl_ns)[l->l_ns]._ns_loaded = NULL;
36 - else
37 - l->l_prev->l_next = NULL;
38 - --GL(dl_ns)[l->l_ns]._ns_nloaded;
39 - free (l);
40 - __rtld_lock_unlock_recursive (GL(dl_load_write_lock));
41 - }
42 + free (l);
43 free (realname);
44
45 if (r != NULL)
46 @@ -897,6 +882,9 @@ _dl_map_object_from_fd (const char *name
47 never be unloaded. */
48 __close (fd);
49
50 + /* Add the map for the mirrored object to the object list. */
51 + _dl_add_to_namespace_list (l, nsid);
52 +
53 return l;
54 }
55 #endif
56 @@ -1491,6 +1479,9 @@ cannot enable executable stack as shared
57 add_name_to_object (l, ((const char *) D_PTR (l, l_info[DT_STRTAB])
58 + l->l_info[DT_SONAME]->d_un.d_val));
59
60 + /* Now that the object is fully initialized add it to the object list. */
61 + _dl_add_to_namespace_list (l, nsid);
62 +
63 #ifdef SHARED
64 /* Auditing checkpoint: we have a new object. */
65 if (__builtin_expect (GLRO(dl_naudit) > 0, 0)
66 @@ -2215,7 +2206,7 @@ _dl_map_object (struct link_map *loader,
67 have. */
68 static const Elf_Symndx dummy_bucket = STN_UNDEF;
69
70 - /* Enter the new object in the list of loaded objects. */
71 + /* Allocate a new object map. */
72 if ((name_copy = local_strdup (name)) == NULL
73 || (l = _dl_new_object (name_copy, name, type, loader,
74 mode, nsid)) == NULL)
75 @@ -2233,6 +2224,9 @@ _dl_map_object (struct link_map *loader,
76 l->l_nbuckets = 1;
77 l->l_relocated = 1;
78
79 + /* Enter the object in the object list. */
80 + _dl_add_to_namespace_list (l, nsid);
81 +
82 return l;
83 }
84 else if (found_other_class)
85 Index: glibc-2.12-2-gc4ccff1/elf/dl-object.c
86 ===================================================================
87 --- glibc-2.12-2-gc4ccff1.orig/elf/dl-object.c
88 +++ glibc-2.12-2-gc4ccff1/elf/dl-object.c
89 @@ -26,16 +26,41 @@
90 #include <assert.h>
91
92
93 +/* Add the new link_map NEW to the end of the namespace list. */
94 +void
95 +internal_function
96 +_dl_add_to_namespace_list (struct link_map *new, Lmid_t nsid)
97 +{
98 + /* We modify the list of loaded objects. */
99 + __rtld_lock_lock_recursive (GL(dl_load_write_lock));
100 +
101 + if (GL(dl_ns)[nsid]._ns_loaded != NULL)
102 + {
103 + struct link_map *l = GL(dl_ns)[nsid]._ns_loaded;
104 + while (l->l_next != NULL)
105 + l = l->l_next;
106 + new->l_prev = l;
107 + /* new->l_next = NULL; Would be necessary but we use calloc. */
108 + l->l_next = new;
109 + }
110 + else
111 + GL(dl_ns)[nsid]._ns_loaded = new;
112 + ++GL(dl_ns)[nsid]._ns_nloaded;
113 + new->l_serial = GL(dl_load_adds);
114 + ++GL(dl_load_adds);
115 +
116 + __rtld_lock_unlock_recursive (GL(dl_load_write_lock));
117 +}
118 +
119 +
120 /* Allocate a `struct link_map' for a new object being loaded,
121 and enter it into the _dl_loaded list. */
122 -
123 struct link_map *
124 internal_function
125 _dl_new_object (char *realname, const char *libname, int type,
126 struct link_map *loader, int mode, Lmid_t nsid)
127 {
128 struct link_map *l;
129 - int idx;
130 size_t libname_len = strlen (libname) + 1;
131 struct link_map *new;
132 struct libname_list *newname;
133 @@ -93,31 +118,12 @@ _dl_new_object (char *realname, const ch
134 new->l_scope = new->l_scope_mem;
135 new->l_scope_max = sizeof (new->l_scope_mem) / sizeof (new->l_scope_mem[0]);
136
137 - /* We modify the list of loaded objects. */
138 - __rtld_lock_lock_recursive (GL(dl_load_write_lock));
139 -
140 /* Counter for the scopes we have to handle. */
141 - idx = 0;
142 + int idx = 0;
143
144 if (GL(dl_ns)[nsid]._ns_loaded != NULL)
145 - {
146 - l = GL(dl_ns)[nsid]._ns_loaded;
147 - while (l->l_next != NULL)
148 - l = l->l_next;
149 - new->l_prev = l;
150 - /* new->l_next = NULL; Would be necessary but we use calloc. */
151 - l->l_next = new;
152 -
153 - /* Add the global scope. */
154 - new->l_scope[idx++] = &GL(dl_ns)[nsid]._ns_loaded->l_searchlist;
155 - }
156 - else
157 - GL(dl_ns)[nsid]._ns_loaded = new;
158 - ++GL(dl_ns)[nsid]._ns_nloaded;
159 - new->l_serial = GL(dl_load_adds);
160 - ++GL(dl_load_adds);
161 -
162 - __rtld_lock_unlock_recursive (GL(dl_load_write_lock));
163 + /* Add the global scope. */
164 + new->l_scope[idx++] = &GL(dl_ns)[nsid]._ns_loaded->l_searchlist;
165
166 /* If we have no loader the new object acts as it. */
167 if (loader == NULL)
168 Index: glibc-2.12-2-gc4ccff1/elf/rtld.c
169 ===================================================================
170 --- glibc-2.12-2-gc4ccff1.orig/elf/rtld.c
171 +++ glibc-2.12-2-gc4ccff1/elf/rtld.c
172 @@ -1108,11 +1108,15 @@ of this helper program; chances are you
173 main_map = _dl_new_object ((char *) "", "", lt_executable, NULL,
174 __RTLD_OPENEXEC, LM_ID_BASE);
175 assert (main_map != NULL);
176 - assert (main_map == GL(dl_ns)[LM_ID_BASE]._ns_loaded);
177 main_map->l_phdr = phdr;
178 main_map->l_phnum = phnum;
179 main_map->l_entry = *user_entry;
180
181 + /* Even though the link map is not yet fully initialized we can add
182 + it to the map list since there are no possible users running yet. */
183 + _dl_add_to_namespace_list (main_map, LM_ID_BASE);
184 + assert (main_map == GL(dl_ns)[LM_ID_BASE]._ns_loaded);
185 +
186 /* At this point we are in a bit of trouble. We would have to
187 fill in the values for l_dev and l_ino. But in general we
188 do not know where the file is. We also do not handle AT_EXECFD
189 @@ -1380,6 +1384,9 @@ of this helper program; chances are you
190 l->l_libname->name = memcpy (copy, dsoname, len);
191 }
192
193 + /* Add the vDSO to the object list. */
194 + _dl_add_to_namespace_list (l, LM_ID_BASE);
195 +
196 /* Rearrange the list so this DSO appears after rtld_map. */
197 assert (l->l_next == NULL);
198 assert (l->l_prev == main_map);
199 Index: glibc-2.12-2-gc4ccff1/sysdeps/generic/ldsodefs.h
200 ===================================================================
201 --- glibc-2.12-2-gc4ccff1.orig/sysdeps/generic/ldsodefs.h
202 +++ glibc-2.12-2-gc4ccff1/sysdeps/generic/ldsodefs.h
203 @@ -891,8 +891,11 @@ extern lookup_t _dl_lookup_symbol_x (con
204 extern ElfW(Addr) _dl_symbol_value (struct link_map *map, const char *name)
205 internal_function;
206
207 -/* Allocate a `struct link_map' for a new object being loaded,
208 - and enter it into the _dl_main_map list. */
209 +/* Add the new link_map NEW to the end of the namespace list. */
210 +extern void _dl_add_to_namespace_list (struct link_map *new, Lmid_t nsid)
211 + internal_function attribute_hidden;
212 +
213 +/* Allocate a `struct link_map' for a new object being loaded. */
214 extern struct link_map *_dl_new_object (char *realname, const char *libname,
215 int type, struct link_map *loader,
216 int mode, Lmid_t nsid)