Fri Dec 2 09:06:49 2011 UTC ()
Restore backwards compatibility by removing unnecessary addition of
dlvsym to Obj_Entry.

Add some comments.


(skrll)
diff -r1.104 -r1.105 src/libexec/ld.elf_so/reloc.c
diff -r1.106 -r1.107 src/libexec/ld.elf_so/rtld.h

cvs diff -r1.104 -r1.105 src/libexec/ld.elf_so/reloc.c (expand / switch to unified diff)

--- src/libexec/ld.elf_so/reloc.c 2011/06/25 05:45:12 1.104
+++ src/libexec/ld.elf_so/reloc.c 2011/12/02 09:06:49 1.105
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: reloc.c,v 1.104 2011/06/25 05:45:12 nonaka Exp $ */ 1/* $NetBSD: reloc.c,v 1.105 2011/12/02 09:06:49 skrll Exp $ */
2 2
3/* 3/*
4 * Copyright 1996 John D. Polstra. 4 * Copyright 1996 John D. Polstra.
5 * Copyright 1996 Matt Thomas <matt@3am-software.com> 5 * Copyright 1996 Matt Thomas <matt@3am-software.com>
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34/* 34/*
35 * Dynamic linker for ELF. 35 * Dynamic linker for ELF.
36 * 36 *
37 * John Polstra <jdp@polstra.com>. 37 * John Polstra <jdp@polstra.com>.
38 */ 38 */
39 39
40#include <sys/cdefs.h> 40#include <sys/cdefs.h>
41#ifndef lint 41#ifndef lint
42__RCSID("$NetBSD: reloc.c,v 1.104 2011/06/25 05:45:12 nonaka Exp $"); 42__RCSID("$NetBSD: reloc.c,v 1.105 2011/12/02 09:06:49 skrll Exp $");
43#endif /* not lint */ 43#endif /* not lint */
44 44
45#include <err.h> 45#include <err.h>
46#include <errno.h> 46#include <errno.h>
47#include <fcntl.h> 47#include <fcntl.h>
48#include <stdarg.h> 48#include <stdarg.h>
49#include <stdio.h> 49#include <stdio.h>
50#include <stdlib.h> 50#include <stdlib.h>
51#include <string.h> 51#include <string.h>
52#include <unistd.h> 52#include <unistd.h>
53#include <sys/types.h> 53#include <sys/types.h>
54#include <sys/mman.h> 54#include <sys/mman.h>
55#include <sys/bitops.h> 55#include <sys/bitops.h>
@@ -200,29 +200,32 @@ _rtld_relocate_objects(Obj_Entry *first, @@ -200,29 +200,32 @@ _rtld_relocate_objects(Obj_Entry *first,
200#endif 200#endif
201 if (obj->z_now || bind_now) { 201 if (obj->z_now || bind_now) {
202 dbg(("doing immediate PLT binding")); 202 dbg(("doing immediate PLT binding"));
203 if (_rtld_relocate_plt_objects(obj) < 0) 203 if (_rtld_relocate_plt_objects(obj) < 0)
204 ok = 0; 204 ok = 0;
205 } 205 }
206 if (!ok) 206 if (!ok)
207 return -1; 207 return -1;
208 208
209 /* Set some sanity-checking numbers in the Obj_Entry. */ 209 /* Set some sanity-checking numbers in the Obj_Entry. */
210 obj->magic = RTLD_MAGIC; 210 obj->magic = RTLD_MAGIC;
211 obj->version = RTLD_VERSION; 211 obj->version = RTLD_VERSION;
212 212
213 /* Fill in the dynamic linker entry points. */ 213 /*
 214 * Fill in the backwards compatibility dynamic linker entry points.
 215 *
 216 * DO NOT ADD TO THIS LIST
 217 */
214 obj->dlopen = dlopen; 218 obj->dlopen = dlopen;
215 obj->dlsym = dlsym; 219 obj->dlsym = dlsym;
216 obj->dlvsym = dlvsym; 
217 obj->dlerror = dlerror; 220 obj->dlerror = dlerror;
218 obj->dlclose = dlclose; 221 obj->dlclose = dlclose;
219 obj->dladdr = dladdr; 222 obj->dladdr = dladdr;
220 223
221 dbg(("fixing up PLTGOT")); 224 dbg(("fixing up PLTGOT"));
222 /* Set the special PLTGOT entries. */ 225 /* Set the special PLTGOT entries. */
223 if (obj->pltgot != NULL) 226 if (obj->pltgot != NULL)
224 _rtld_setup_pltgot(obj); 227 _rtld_setup_pltgot(obj);
225 } 228 }
226 229
227 return 0; 230 return 0;
228} 231}

cvs diff -r1.106 -r1.107 src/libexec/ld.elf_so/rtld.h (expand / switch to unified diff)

--- src/libexec/ld.elf_so/rtld.h 2011/06/25 05:45:12 1.106
+++ src/libexec/ld.elf_so/rtld.h 2011/12/02 09:06:49 1.107
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rtld.h,v 1.106 2011/06/25 05:45:12 nonaka Exp $ */ 1/* $NetBSD: rtld.h,v 1.107 2011/12/02 09:06:49 skrll Exp $ */
2 2
3/* 3/*
4 * Copyright 1996 John D. Polstra. 4 * Copyright 1996 John D. Polstra.
5 * Copyright 1996 Matt Thomas <matt@3am-software.com> 5 * Copyright 1996 Matt Thomas <matt@3am-software.com>
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -181,30 +181,34 @@ typedef struct Struct_Obj_Entry { @@ -181,30 +181,34 @@ typedef struct Struct_Obj_Entry {
181#endif 181#endif
182 182
183 const Elf_Symindx *buckets; /* Hash table buckets array */ 183 const Elf_Symindx *buckets; /* Hash table buckets array */
184 unsigned long unused1; /* Used to be nbuckets */ 184 unsigned long unused1; /* Used to be nbuckets */
185 const Elf_Symindx *chains; /* Hash table chain array */ 185 const Elf_Symindx *chains; /* Hash table chain array */
186 unsigned long nchains; /* Number of chains */ 186 unsigned long nchains; /* Number of chains */
187 187
188 Search_Path *rpaths; /* Search path specified in object */ 188 Search_Path *rpaths; /* Search path specified in object */
189 Needed_Entry *needed; /* Shared objects needed by this (%) */ 189 Needed_Entry *needed; /* Shared objects needed by this (%) */
190 190
191 void (*init)(void); /* Initialization function to call */ 191 void (*init)(void); /* Initialization function to call */
192 void (*fini)(void); /* Termination function to call */ 192 void (*fini)(void); /* Termination function to call */
193 193
194 /* Entry points for dlopen() and friends. */ 194 /*
 195 * BACKWARDS COMPAT Entry points for dlopen() and friends.
 196 *
 197 * DO NOT MOVE OR ADD TO THE LIST
 198 *
 199 */
195 void *(*dlopen)(const char *, int); 200 void *(*dlopen)(const char *, int);
196 void *(*dlsym)(void *, const char *); 201 void *(*dlsym)(void *, const char *);
197 void *(*dlvsym)(void *, const char *, const char *); 
198 char *(*dlerror)(void); 202 char *(*dlerror)(void);
199 int (*dlclose)(void *); 203 int (*dlclose)(void *);
200 int (*dladdr)(const void *, Dl_info *); 204 int (*dladdr)(const void *, Dl_info *);
201 205
202 u_int32_t mainprog:1, /* True if this is the main program */ 206 u_int32_t mainprog:1, /* True if this is the main program */
203 rtld:1, /* True if this is the dynamic linker */ 207 rtld:1, /* True if this is the dynamic linker */
204 textrel:1, /* True if there are relocations to 208 textrel:1, /* True if there are relocations to
205 * text seg */ 209 * text seg */
206 symbolic:1, /* True if generated with 210 symbolic:1, /* True if generated with
207 * "-Bsymbolic" */ 211 * "-Bsymbolic" */
208 printed:1, /* True if ldd has printed it */ 212 printed:1, /* True if ldd has printed it */
209 isdynamic:1, /* True if this is a pure PIC object */ 213 isdynamic:1, /* True if this is a pure PIC object */
210 mainref:1, /* True if on _rtld_list_main */ 214 mainref:1, /* True if on _rtld_list_main */