Mon Mar 16 02:46:48 2009 UTC ()
Fix const issues (cast const pointers to "const uint8_t *" instead of "caddr_t")

NOTE: change based on ../i386/mdreloc.c 1.27
XXX: not compile tested


(lukem)
diff -r1.28 -r1.29 src/libexec/ld.elf_so/arch/arm/mdreloc.c
diff -r1.22 -r1.23 src/libexec/ld.elf_so/arch/m68k/mdreloc.c
diff -r1.24 -r1.25 src/libexec/ld.elf_so/arch/sh3/mdreloc.c
diff -r1.41 -r1.42 src/libexec/ld.elf_so/arch/sparc/mdreloc.c
diff -r1.43 -r1.44 src/libexec/ld.elf_so/arch/sparc64/mdreloc.c
diff -r1.23 -r1.24 src/libexec/ld.elf_so/arch/vax/mdreloc.c

cvs diff -r1.28 -r1.29 src/libexec/ld.elf_so/arch/arm/mdreloc.c (expand / switch to unified diff)

--- src/libexec/ld.elf_so/arch/arm/mdreloc.c 2008/07/24 04:39:25 1.28
+++ src/libexec/ld.elf_so/arch/arm/mdreloc.c 2009/03/16 02:46:47 1.29
@@ -1,18 +1,18 @@ @@ -1,18 +1,18 @@
1/* $NetBSD: mdreloc.c,v 1.28 2008/07/24 04:39:25 matt Exp $ */ 1/* $NetBSD: mdreloc.c,v 1.29 2009/03/16 02:46:47 lukem Exp $ */
2 2
3#include <sys/cdefs.h> 3#include <sys/cdefs.h>
4#ifndef lint 4#ifndef lint
5__RCSID("$NetBSD: mdreloc.c,v 1.28 2008/07/24 04:39:25 matt Exp $"); 5__RCSID("$NetBSD: mdreloc.c,v 1.29 2009/03/16 02:46:47 lukem Exp $");
6#endif /* not lint */ 6#endif /* not lint */
7 7
8#include <sys/types.h> 8#include <sys/types.h>
9#include <sys/stat.h> 9#include <sys/stat.h>
10 10
11#include <string.h> 11#include <string.h>
12 12
13#include "debug.h" 13#include "debug.h"
14#include "rtld.h" 14#include "rtld.h"
15 15
16void _rtld_bind_start(void); 16void _rtld_bind_start(void);
17void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr); 17void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
18caddr_t _rtld_bind(const Obj_Entry *, Elf_Word); 18caddr_t _rtld_bind(const Obj_Entry *, Elf_Word);
@@ -31,27 +31,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp @@ -31,27 +31,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp
31 Elf_Addr relsz = 0; 31 Elf_Addr relsz = 0;
32 Elf_Addr *where; 32 Elf_Addr *where;
33 33
34 for (; dynp->d_tag != DT_NULL; dynp++) { 34 for (; dynp->d_tag != DT_NULL; dynp++) {
35 switch (dynp->d_tag) { 35 switch (dynp->d_tag) {
36 case DT_REL: 36 case DT_REL:
37 rel = (const Elf_Rel *)(relocbase + dynp->d_un.d_ptr); 37 rel = (const Elf_Rel *)(relocbase + dynp->d_un.d_ptr);
38 break; 38 break;
39 case DT_RELSZ: 39 case DT_RELSZ:
40 relsz = dynp->d_un.d_val; 40 relsz = dynp->d_un.d_val;
41 break; 41 break;
42 } 42 }
43 } 43 }
44 rellim = (const Elf_Rel *)((caddr_t)rel + relsz); 44 rellim = (const Elf_Rel *)((const uint8_t *)rel + relsz);
45 for (; rel < rellim; rel++) { 45 for (; rel < rellim; rel++) {
46 where = (Elf_Addr *)(relocbase + rel->r_offset); 46 where = (Elf_Addr *)(relocbase + rel->r_offset);
47 *where += (Elf_Addr)relocbase; 47 *where += (Elf_Addr)relocbase;
48 } 48 }
49} 49}
50 50
51/* 51/*
52 * It is possible for the compiler to emit relocations for unaligned data. 52 * It is possible for the compiler to emit relocations for unaligned data.
53 * We handle this situation with these inlines. 53 * We handle this situation with these inlines.
54 */ 54 */
55#define RELOC_ALIGNED_P(x) \ 55#define RELOC_ALIGNED_P(x) \
56 (((uintptr_t)(x) & (sizeof(void *) - 1)) == 0) 56 (((uintptr_t)(x) & (sizeof(void *) - 1)) == 0)
57 57
@@ -239,27 +239,27 @@ _rtld_relocate_plt_object(const Obj_Entr @@ -239,27 +239,27 @@ _rtld_relocate_plt_object(const Obj_Entr
239 rdbg(("bind now/fixup in %s --> old=%p new=%p", 239 rdbg(("bind now/fixup in %s --> old=%p new=%p",
240 defobj->strtab + def->st_name, (void *)*where, (void *)new_value)); 240 defobj->strtab + def->st_name, (void *)*where, (void *)new_value));
241 if (*where != new_value) 241 if (*where != new_value)
242 *where = new_value; 242 *where = new_value;
243 if (tp) 243 if (tp)
244 *tp = new_value; 244 *tp = new_value;
245 245
246 return 0; 246 return 0;
247} 247}
248 248
249caddr_t 249caddr_t
250_rtld_bind(const Obj_Entry *obj, Elf_Word reloff) 250_rtld_bind(const Obj_Entry *obj, Elf_Word reloff)
251{ 251{
252 const Elf_Rel *rel = (const Elf_Rel *)((caddr_t)obj->pltrel + reloff); 252 const Elf_Rel *rel = (const Elf_Rel *)((const uint8_t *)obj->pltrel + reloff);
253 Elf_Addr new_value; 253 Elf_Addr new_value;
254 int err; 254 int err;
255 255
256 err = _rtld_relocate_plt_object(obj, rel, &new_value); 256 err = _rtld_relocate_plt_object(obj, rel, &new_value);
257 if (err || new_value == 0) 257 if (err || new_value == 0)
258 _rtld_die(); 258 _rtld_die();
259 259
260 return (caddr_t)new_value; 260 return (caddr_t)new_value;
261} 261}
262int 262int
263_rtld_relocate_plt_objects(const Obj_Entry *obj) 263_rtld_relocate_plt_objects(const Obj_Entry *obj)
264{ 264{
265 const Elf_Rel *rel; 265 const Elf_Rel *rel;

cvs diff -r1.22 -r1.23 src/libexec/ld.elf_so/arch/m68k/mdreloc.c (expand / switch to unified diff)

--- src/libexec/ld.elf_so/arch/m68k/mdreloc.c 2008/07/24 06:51:58 1.22
+++ src/libexec/ld.elf_so/arch/m68k/mdreloc.c 2009/03/16 02:46:47 1.23
@@ -1,23 +1,23 @@ @@ -1,23 +1,23 @@
1/* $NetBSD: mdreloc.c,v 1.22 2008/07/24 06:51:58 skrll Exp $ */ 1/* $NetBSD: mdreloc.c,v 1.23 2009/03/16 02:46:47 lukem Exp $ */
2 2
3#include <sys/cdefs.h> 3#include <sys/cdefs.h>
4#ifndef lint 4#ifndef lint
5__RCSID("$NetBSD: mdreloc.c,v 1.22 2008/07/24 06:51:58 skrll Exp $"); 5__RCSID("$NetBSD: mdreloc.c,v 1.23 2009/03/16 02:46:47 lukem Exp $");
6#endif /* not lint */ 6#endif /* not lint */
7 7
8#include <sys/cdefs.h> 8#include <sys/cdefs.h>
9#ifndef lint 9#ifndef lint
10__RCSID("$NetBSD: mdreloc.c,v 1.22 2008/07/24 06:51:58 skrll Exp $"); 10__RCSID("$NetBSD: mdreloc.c,v 1.23 2009/03/16 02:46:47 lukem Exp $");
11#endif /* not lint */ 11#endif /* not lint */
12 12
13#include <sys/types.h> 13#include <sys/types.h>
14#include <sys/stat.h> 14#include <sys/stat.h>
15 15
16#include "debug.h" 16#include "debug.h"
17#include "rtld.h" 17#include "rtld.h"
18 18
19void _rtld_bind_start(void); 19void _rtld_bind_start(void);
20void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr); 20void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
21caddr_t _rtld_bind(const Obj_Entry *, Elf_Word); 21caddr_t _rtld_bind(const Obj_Entry *, Elf_Word);
22static inline int _rtld_relocate_plt_object(const Obj_Entry *, 22static inline int _rtld_relocate_plt_object(const Obj_Entry *,
23 const Elf_Rela *, Elf_Addr *); 23 const Elf_Rela *, Elf_Addr *);
@@ -37,27 +37,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp @@ -37,27 +37,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp
37 Elf_Addr relasz = 0; 37 Elf_Addr relasz = 0;
38 Elf_Addr *where; 38 Elf_Addr *where;
39 39
40 for (; dynp->d_tag != DT_NULL; dynp++) { 40 for (; dynp->d_tag != DT_NULL; dynp++) {
41 switch (dynp->d_tag) { 41 switch (dynp->d_tag) {
42 case DT_RELA: 42 case DT_RELA:
43 rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr); 43 rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr);
44 break; 44 break;
45 case DT_RELASZ: 45 case DT_RELASZ:
46 relasz = dynp->d_un.d_val; 46 relasz = dynp->d_un.d_val;
47 break; 47 break;
48 } 48 }
49 } 49 }
50 relalim = (const Elf_Rela *)((caddr_t)rela + relasz); 50 relalim = (const Elf_Rela *)((const uint8_t *)rela + relasz);
51 for (; rela < relalim; rela++) { 51 for (; rela < relalim; rela++) {
52 where = (Elf_Addr *)(relocbase + rela->r_offset); 52 where = (Elf_Addr *)(relocbase + rela->r_offset);
53 *where += (Elf_Addr)relocbase; 53 *where += (Elf_Addr)relocbase;
54 } 54 }
55} 55}
56 56
57int 57int
58_rtld_relocate_nonplt_objects(const Obj_Entry *obj) 58_rtld_relocate_nonplt_objects(const Obj_Entry *obj)
59{ 59{
60 const Elf_Rela *rela; 60 const Elf_Rela *rela;
61 61
62 for (rela = obj->rela; rela < obj->relalim; rela++) { 62 for (rela = obj->rela; rela < obj->relalim; rela++) {
63 Elf_Addr *where; 63 Elf_Addr *where;
@@ -185,27 +185,27 @@ _rtld_relocate_plt_object(const Obj_Entr @@ -185,27 +185,27 @@ _rtld_relocate_plt_object(const Obj_Entr
185 defobj->strtab + def->st_name, (void *)*where, (void *)new_value)); 185 defobj->strtab + def->st_name, (void *)*where, (void *)new_value));
186 if (*where != new_value) 186 if (*where != new_value)
187 *where = new_value; 187 *where = new_value;
188 188
189 if (tp) 189 if (tp)
190 *tp = new_value - rela->r_addend; 190 *tp = new_value - rela->r_addend;
191 191
192 return 0; 192 return 0;
193} 193}
194 194
195caddr_t 195caddr_t
196_rtld_bind(const Obj_Entry *obj, Elf_Word reloff) 196_rtld_bind(const Obj_Entry *obj, Elf_Word reloff)
197{ 197{
198 const Elf_Rela *rela = (const Elf_Rela *)((caddr_t)obj->pltrela + reloff); 198 const Elf_Rela *rela = (const Elf_Rela *)((const uint8_t *)obj->pltrela + reloff);
199 Elf_Addr result; 199 Elf_Addr result;
200 int err; 200 int err;
201 201
202 result = 0; /* XXX gcc */ 202 result = 0; /* XXX gcc */
203 203
204 err = _rtld_relocate_plt_object(obj, rela, &result); 204 err = _rtld_relocate_plt_object(obj, rela, &result);
205 if (err || result == 0) 205 if (err || result == 0)
206 _rtld_die(); 206 _rtld_die();
207 207
208 return (caddr_t)result; 208 return (caddr_t)result;
209} 209}
210 210
211int 211int

cvs diff -r1.24 -r1.25 src/libexec/ld.elf_so/arch/sh3/mdreloc.c (expand / switch to unified diff)

--- src/libexec/ld.elf_so/arch/sh3/mdreloc.c 2008/07/24 06:51:58 1.24
+++ src/libexec/ld.elf_so/arch/sh3/mdreloc.c 2009/03/16 02:46:47 1.25
@@ -1,23 +1,23 @@ @@ -1,23 +1,23 @@
1/* $NetBSD: mdreloc.c,v 1.24 2008/07/24 06:51:58 skrll Exp $ */ 1/* $NetBSD: mdreloc.c,v 1.25 2009/03/16 02:46:47 lukem Exp $ */
2 2
3#include <sys/cdefs.h> 3#include <sys/cdefs.h>
4#ifndef lint 4#ifndef lint
5__RCSID("$NetBSD: mdreloc.c,v 1.24 2008/07/24 06:51:58 skrll Exp $"); 5__RCSID("$NetBSD: mdreloc.c,v 1.25 2009/03/16 02:46:47 lukem Exp $");
6#endif /* not lint */ 6#endif /* not lint */
7 7
8#include <sys/cdefs.h> 8#include <sys/cdefs.h>
9#ifndef lint 9#ifndef lint
10__RCSID("$NetBSD: mdreloc.c,v 1.24 2008/07/24 06:51:58 skrll Exp $"); 10__RCSID("$NetBSD: mdreloc.c,v 1.25 2009/03/16 02:46:47 lukem Exp $");
11#endif /* not lint */ 11#endif /* not lint */
12 12
13#include <sys/types.h> 13#include <sys/types.h>
14#include <sys/stat.h> 14#include <sys/stat.h>
15 15
16#include "debug.h" 16#include "debug.h"
17#include "rtld.h" 17#include "rtld.h"
18 18
19void _rtld_bind_start(void); 19void _rtld_bind_start(void);
20void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr); 20void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
21caddr_t _rtld_bind(const Obj_Entry *, Elf_Word); 21caddr_t _rtld_bind(const Obj_Entry *, Elf_Word);
22static inline int _rtld_relocate_plt_object(const Obj_Entry *, 22static inline int _rtld_relocate_plt_object(const Obj_Entry *,
23 const Elf_Rela *, Elf_Addr *); 23 const Elf_Rela *, Elf_Addr *);
@@ -36,27 +36,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp @@ -36,27 +36,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp
36 Elf_Addr relasz = 0; 36 Elf_Addr relasz = 0;
37 Elf_Addr *where; 37 Elf_Addr *where;
38 38
39 for (; dynp->d_tag != DT_NULL; dynp++) { 39 for (; dynp->d_tag != DT_NULL; dynp++) {
40 switch (dynp->d_tag) { 40 switch (dynp->d_tag) {
41 case DT_RELA: 41 case DT_RELA:
42 rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr); 42 rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr);
43 break; 43 break;
44 case DT_RELASZ: 44 case DT_RELASZ:
45 relasz = dynp->d_un.d_val; 45 relasz = dynp->d_un.d_val;
46 break; 46 break;
47 } 47 }
48 } 48 }
49 relalim = (const Elf_Rela *)((caddr_t)rela + relasz); 49 relalim = (const Elf_Rela *)((const uint8_t *)rela + relasz);
50 for (; rela < relalim; rela++) { 50 for (; rela < relalim; rela++) {
51 where = (Elf_Addr *)(relocbase + rela->r_offset); 51 where = (Elf_Addr *)(relocbase + rela->r_offset);
52 *where = (Elf_Addr)(relocbase + rela->r_addend); 52 *where = (Elf_Addr)(relocbase + rela->r_addend);
53 } 53 }
54} 54}
55 55
56int 56int
57_rtld_relocate_nonplt_objects(const Obj_Entry *obj) 57_rtld_relocate_nonplt_objects(const Obj_Entry *obj)
58{ 58{
59 const Elf_Rela *rela; 59 const Elf_Rela *rela;
60 60
61 for (rela = obj->rela; rela < obj->relalim; rela++) { 61 for (rela = obj->rela; rela < obj->relalim; rela++) {
62 Elf_Addr *where; 62 Elf_Addr *where;
@@ -185,27 +185,27 @@ _rtld_relocate_plt_lazy(const Obj_Entry  @@ -185,27 +185,27 @@ _rtld_relocate_plt_lazy(const Obj_Entry
185 assert(ELF_R_TYPE(rela->r_info) == R_TYPE(JMP_SLOT)); 185 assert(ELF_R_TYPE(rela->r_info) == R_TYPE(JMP_SLOT));
186 186
187 /* Just relocate the GOT slots pointing into the PLT */ 187 /* Just relocate the GOT slots pointing into the PLT */
188 *where += (Elf_Addr)obj->relocbase; 188 *where += (Elf_Addr)obj->relocbase;
189 rdbg(("fixup !main in %s --> %p", obj->path, (void *)*where)); 189 rdbg(("fixup !main in %s --> %p", obj->path, (void *)*where));
190 } 190 }
191 191
192 return 0; 192 return 0;
193} 193}
194 194
195caddr_t 195caddr_t
196_rtld_bind(const Obj_Entry *obj, Elf_Word reloff) 196_rtld_bind(const Obj_Entry *obj, Elf_Word reloff)
197{ 197{
198 const Elf_Rela *rela = (const Elf_Rela *)((caddr_t)obj->pltrela + reloff); 198 const Elf_Rela *rela = (const Elf_Rela *)((const uint8_t *)obj->pltrela + reloff);
199 Elf_Addr new_value; 199 Elf_Addr new_value;
200 int err; 200 int err;
201 201
202 new_value = 0; /* XXX gcc */ 202 new_value = 0; /* XXX gcc */
203 203
204 err = _rtld_relocate_plt_object(obj, rela, &new_value); 204 err = _rtld_relocate_plt_object(obj, rela, &new_value);
205 if (err || new_value == 0) 205 if (err || new_value == 0)
206 _rtld_die(); 206 _rtld_die();
207 207
208 return (caddr_t)new_value; 208 return (caddr_t)new_value;
209} 209}
210 210
211int 211int

cvs diff -r1.41 -r1.42 src/libexec/ld.elf_so/arch/sparc/mdreloc.c (expand / switch to unified diff)

--- src/libexec/ld.elf_so/arch/sparc/mdreloc.c 2008/07/24 04:39:25 1.41
+++ src/libexec/ld.elf_so/arch/sparc/mdreloc.c 2009/03/16 02:46:47 1.42
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mdreloc.c,v 1.41 2008/07/24 04:39:25 matt Exp $ */ 1/* $NetBSD: mdreloc.c,v 1.42 2009/03/16 02:46:47 lukem Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Paul Kranenburg and by Charles M. Hannum. 8 * by Paul Kranenburg and by Charles M. Hannum.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__RCSID("$NetBSD: mdreloc.c,v 1.41 2008/07/24 04:39:25 matt Exp $"); 34__RCSID("$NetBSD: mdreloc.c,v 1.42 2009/03/16 02:46:47 lukem Exp $");
35#endif /* not lint */ 35#endif /* not lint */
36 36
37#include <errno.h> 37#include <errno.h>
38#include <stdio.h> 38#include <stdio.h>
39#include <stdlib.h> 39#include <stdlib.h>
40#include <string.h> 40#include <string.h>
41#include <unistd.h> 41#include <unistd.h>
42#include <sys/stat.h> 42#include <sys/stat.h>
43 43
44#include "rtldenv.h" 44#include "rtldenv.h"
45#include "debug.h" 45#include "debug.h"
46#include "rtld.h" 46#include "rtld.h"
47 47
@@ -163,27 +163,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp @@ -163,27 +163,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp
163 Elf_Addr relasz = 0; 163 Elf_Addr relasz = 0;
164 Elf_Addr *where; 164 Elf_Addr *where;
165 165
166 for (; dynp->d_tag != DT_NULL; dynp++) { 166 for (; dynp->d_tag != DT_NULL; dynp++) {
167 switch (dynp->d_tag) { 167 switch (dynp->d_tag) {
168 case DT_RELA: 168 case DT_RELA:
169 rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr); 169 rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr);
170 break; 170 break;
171 case DT_RELASZ: 171 case DT_RELASZ:
172 relasz = dynp->d_un.d_val; 172 relasz = dynp->d_un.d_val;
173 break; 173 break;
174 } 174 }
175 } 175 }
176 relalim = (const Elf_Rela *)((caddr_t)rela + relasz); 176 relalim = (const Elf_Rela *)((const uint8_t *)rela + relasz);
177 for (; rela < relalim; rela++) { 177 for (; rela < relalim; rela++) {
178 where = (Elf_Addr *)(relocbase + rela->r_offset); 178 where = (Elf_Addr *)(relocbase + rela->r_offset);
179 *where += (Elf_Addr)(relocbase + rela->r_addend); 179 *where += (Elf_Addr)(relocbase + rela->r_addend);
180 } 180 }
181} 181}
182 182
183int 183int
184_rtld_relocate_nonplt_objects(const Obj_Entry *obj) 184_rtld_relocate_nonplt_objects(const Obj_Entry *obj)
185{ 185{
186 const Elf_Rela *rela; 186 const Elf_Rela *rela;
187 187
188 for (rela = obj->rela; rela < obj->relalim; rela++) { 188 for (rela = obj->rela; rela < obj->relalim; rela++) {
189 Elf_Addr *where; 189 Elf_Addr *where;
@@ -310,27 +310,27 @@ _rtld_relocate_nonplt_objects(const Obj_ @@ -310,27 +310,27 @@ _rtld_relocate_nonplt_objects(const Obj_
310 } 310 }
311 return (0); 311 return (0);
312} 312}
313 313
314int 314int
315_rtld_relocate_plt_lazy(const Obj_Entry *obj) 315_rtld_relocate_plt_lazy(const Obj_Entry *obj)
316{ 316{
317 return (0); 317 return (0);
318} 318}
319 319
320caddr_t 320caddr_t
321_rtld_bind(const Obj_Entry *obj, Elf_Word reloff) 321_rtld_bind(const Obj_Entry *obj, Elf_Word reloff)
322{ 322{
323 const Elf_Rela *rela = (const Elf_Rela *)((caddr_t)obj->pltrela + reloff); 323 const Elf_Rela *rela = (const Elf_Rela *)((const uint8_t *)obj->pltrela + reloff);
324 Elf_Addr value; 324 Elf_Addr value;
325 int err; 325 int err;
326 326
327 value = 0; /* XXX gcc */ 327 value = 0; /* XXX gcc */
328 328
329 err = _rtld_relocate_plt_object(obj, rela, &value); 329 err = _rtld_relocate_plt_object(obj, rela, &value);
330 if (err || value == 0) 330 if (err || value == 0)
331 _rtld_die(); 331 _rtld_die();
332 332
333 return (caddr_t)value; 333 return (caddr_t)value;
334} 334}
335 335
336int 336int

cvs diff -r1.43 -r1.44 src/libexec/ld.elf_so/arch/sparc64/mdreloc.c (expand / switch to unified diff)

--- src/libexec/ld.elf_so/arch/sparc64/mdreloc.c 2008/07/24 04:39:25 1.43
+++ src/libexec/ld.elf_so/arch/sparc64/mdreloc.c 2009/03/16 02:46:48 1.44
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mdreloc.c,v 1.43 2008/07/24 04:39:25 matt Exp $ */ 1/* $NetBSD: mdreloc.c,v 1.44 2009/03/16 02:46:48 lukem Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000 Eduardo Horvath. 4 * Copyright (c) 2000 Eduardo Horvath.
5 * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc. 5 * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Paul Kranenburg and by Charles M. Hannum. 9 * by Paul Kranenburg and by Charles M. Hannum.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE. 30 * POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34#ifndef lint 34#ifndef lint
35__RCSID("$NetBSD: mdreloc.c,v 1.43 2008/07/24 04:39:25 matt Exp $"); 35__RCSID("$NetBSD: mdreloc.c,v 1.44 2009/03/16 02:46:48 lukem Exp $");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38#include <errno.h> 38#include <errno.h>
39#include <stdio.h> 39#include <stdio.h>
40#include <stdlib.h> 40#include <stdlib.h>
41#include <string.h> 41#include <string.h>
42#include <unistd.h> 42#include <unistd.h>
43#include <sys/stat.h> 43#include <sys/stat.h>
44 44
45#include "rtldenv.h" 45#include "rtldenv.h"
46#include "debug.h" 46#include "debug.h"
47#include "rtld.h" 47#include "rtld.h"
48 48
@@ -279,27 +279,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp @@ -279,27 +279,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp
279 Elf_Addr relasz = 0; 279 Elf_Addr relasz = 0;
280 Elf_Addr *where; 280 Elf_Addr *where;
281 281
282 for (; dynp->d_tag != DT_NULL; dynp++) { 282 for (; dynp->d_tag != DT_NULL; dynp++) {
283 switch (dynp->d_tag) { 283 switch (dynp->d_tag) {
284 case DT_RELA: 284 case DT_RELA:
285 rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr); 285 rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr);
286 break; 286 break;
287 case DT_RELASZ: 287 case DT_RELASZ:
288 relasz = dynp->d_un.d_val; 288 relasz = dynp->d_un.d_val;
289 break; 289 break;
290 } 290 }
291 } 291 }
292 relalim = (const Elf_Rela *)((caddr_t)rela + relasz); 292 relalim = (const Elf_Rela *)((const uint8_t *)rela + relasz);
293 for (; rela < relalim; rela++) { 293 for (; rela < relalim; rela++) {
294 where = (Elf_Addr *)(relocbase + rela->r_offset); 294 where = (Elf_Addr *)(relocbase + rela->r_offset);
295 *where = (Elf_Addr)(relocbase + rela->r_addend); 295 *where = (Elf_Addr)(relocbase + rela->r_addend);
296 } 296 }
297} 297}
298 298
299int 299int
300_rtld_relocate_nonplt_objects(const Obj_Entry *obj) 300_rtld_relocate_nonplt_objects(const Obj_Entry *obj)
301{ 301{
302 const Elf_Rela *rela; 302 const Elf_Rela *rela;
303 const Elf_Sym *def = NULL; 303 const Elf_Sym *def = NULL;
304 const Obj_Entry *defobj = NULL; 304 const Obj_Entry *defobj = NULL;
305 305

cvs diff -r1.23 -r1.24 src/libexec/ld.elf_so/arch/vax/mdreloc.c (expand / switch to unified diff)

--- src/libexec/ld.elf_so/arch/vax/mdreloc.c 2008/07/24 06:51:59 1.23
+++ src/libexec/ld.elf_so/arch/vax/mdreloc.c 2009/03/16 02:46:48 1.24
@@ -1,23 +1,23 @@ @@ -1,23 +1,23 @@
1/* $NetBSD: mdreloc.c,v 1.23 2008/07/24 06:51:59 skrll Exp $ */ 1/* $NetBSD: mdreloc.c,v 1.24 2009/03/16 02:46:48 lukem Exp $ */
2 2
3#include <sys/cdefs.h> 3#include <sys/cdefs.h>
4#ifndef lint 4#ifndef lint
5__RCSID("$NetBSD: mdreloc.c,v 1.23 2008/07/24 06:51:59 skrll Exp $"); 5__RCSID("$NetBSD: mdreloc.c,v 1.24 2009/03/16 02:46:48 lukem Exp $");
6#endif /* not lint */ 6#endif /* not lint */
7 7
8#include <sys/cdefs.h> 8#include <sys/cdefs.h>
9#ifndef lint 9#ifndef lint
10__RCSID("$NetBSD: mdreloc.c,v 1.23 2008/07/24 06:51:59 skrll Exp $"); 10__RCSID("$NetBSD: mdreloc.c,v 1.24 2009/03/16 02:46:48 lukem Exp $");
11#endif /* not lint */ 11#endif /* not lint */
12 12
13#include <sys/types.h> 13#include <sys/types.h>
14#include <sys/stat.h> 14#include <sys/stat.h>
15 15
16#include "debug.h" 16#include "debug.h"
17#include "rtld.h" 17#include "rtld.h"
18 18
19void _rtld_bind_start(void); 19void _rtld_bind_start(void);
20void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr); 20void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
21caddr_t _rtld_bind(const Obj_Entry *, Elf_Word); 21caddr_t _rtld_bind(const Obj_Entry *, Elf_Word);
22static inline int _rtld_relocate_plt_object(const Obj_Entry *, 22static inline int _rtld_relocate_plt_object(const Obj_Entry *,
23 const Elf_Rela *, Elf_Addr *); 23 const Elf_Rela *, Elf_Addr *);
@@ -36,27 +36,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp @@ -36,27 +36,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp
36 Elf_Addr relasz = 0; 36 Elf_Addr relasz = 0;
37 Elf_Addr *where; 37 Elf_Addr *where;
38 38
39 for (; dynp->d_tag != DT_NULL; dynp++) { 39 for (; dynp->d_tag != DT_NULL; dynp++) {
40 switch (dynp->d_tag) { 40 switch (dynp->d_tag) {
41 case DT_RELA: 41 case DT_RELA:
42 rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr); 42 rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr);
43 break; 43 break;
44 case DT_RELASZ: 44 case DT_RELASZ:
45 relasz = dynp->d_un.d_val; 45 relasz = dynp->d_un.d_val;
46 break; 46 break;
47 } 47 }
48 } 48 }
49 relalim = (const Elf_Rela *)((caddr_t)rela + relasz); 49 relalim = (const Elf_Rela *)((const uint8_t *)rela + relasz);
50 for (; rela < relalim; rela++) { 50 for (; rela < relalim; rela++) {
51 where = (Elf_Addr *)(relocbase + rela->r_offset); 51 where = (Elf_Addr *)(relocbase + rela->r_offset);
52 *where = (Elf_Addr)(relocbase + rela->r_addend); 52 *where = (Elf_Addr)(relocbase + rela->r_addend);
53 } 53 }
54} 54}
55 55
56int 56int
57_rtld_relocate_nonplt_objects(const Obj_Entry *obj) 57_rtld_relocate_nonplt_objects(const Obj_Entry *obj)
58{ 58{
59 const Elf_Rela *rela; 59 const Elf_Rela *rela;
60 60
61 for (rela = obj->rela; rela < obj->relalim; rela++) { 61 for (rela = obj->rela; rela < obj->relalim; rela++) {
62 Elf_Addr *where; 62 Elf_Addr *where;
@@ -169,27 +169,27 @@ _rtld_relocate_plt_object(const Obj_Entr @@ -169,27 +169,27 @@ _rtld_relocate_plt_object(const Obj_Entr
169 defobj->strtab + def->st_name, (void *)*where, (void *)new_value)); 169 defobj->strtab + def->st_name, (void *)*where, (void *)new_value));
170 if (*where != new_value) 170 if (*where != new_value)
171 *where = new_value; 171 *where = new_value;
172 172
173 if (tp) 173 if (tp)
174 *tp = new_value - rela->r_addend; 174 *tp = new_value - rela->r_addend;
175 175
176 return 0; 176 return 0;
177} 177}
178 178
179caddr_t 179caddr_t
180_rtld_bind(const Obj_Entry *obj, Elf_Word reloff) 180_rtld_bind(const Obj_Entry *obj, Elf_Word reloff)
181{ 181{
182 const Elf_Rela *rela = (const Elf_Rela *)((caddr_t)obj->pltrela + reloff); 182 const Elf_Rela *rela = (const Elf_Rela *)((const uint8_t *)obj->pltrela + reloff);
183 Elf_Addr result; 183 Elf_Addr result;
184 int err; 184 int err;
185 185
186 result = 0; /* XXX gcc */ 186 result = 0; /* XXX gcc */
187 187
188 err = _rtld_relocate_plt_object(obj, rela, &result); 188 err = _rtld_relocate_plt_object(obj, rela, &result);
189 if (err || result == 0) 189 if (err || result == 0)
190 _rtld_die(); 190 _rtld_die();
191 191
192 return (caddr_t)result; 192 return (caddr_t)result;
193} 193}
194 194
195int 195int