| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ppc_reloc.c,v 1.41 2008/07/24 04:39:25 matt Exp $ */ | | 1 | /* $NetBSD: ppc_reloc.c,v 1.42 2009/05/24 20:35:41 he Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (C) 1998 Tsubai Masanari | | 4 | * Copyright (C) 1998 Tsubai Masanari |
5 | * Portions copyright 2002 Charles M. Hannum <root@ihack.net> | | 5 | * Portions copyright 2002 Charles M. Hannum <root@ihack.net> |
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 |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | | 29 | */ |
30 | | | 30 | |
31 | #include <sys/cdefs.h> | | 31 | #include <sys/cdefs.h> |
32 | #ifndef lint | | 32 | #ifndef lint |
33 | __RCSID("$NetBSD: ppc_reloc.c,v 1.41 2008/07/24 04:39:25 matt Exp $"); | | 33 | __RCSID("$NetBSD: ppc_reloc.c,v 1.42 2009/05/24 20:35:41 he Exp $"); |
34 | #endif /* not lint */ | | 34 | #endif /* not lint */ |
35 | | | 35 | |
36 | #include <stdarg.h> | | 36 | #include <stdarg.h> |
37 | #include <stdio.h> | | 37 | #include <stdio.h> |
38 | #include <stdlib.h> | | 38 | #include <stdlib.h> |
39 | #include <string.h> | | 39 | #include <string.h> |
40 | #include <sys/types.h> | | 40 | #include <sys/types.h> |
41 | #include <sys/stat.h> | | 41 | #include <sys/stat.h> |
42 | #include <machine/cpu.h> | | 42 | #include <machine/cpu.h> |
43 | | | 43 | |
44 | #include "debug.h" | | 44 | #include "debug.h" |
45 | #include "rtld.h" | | 45 | #include "rtld.h" |
46 | | | 46 | |
| @@ -113,27 +113,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp | | | @@ -113,27 +113,27 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp |
113 | Elf_Addr relasz = 0; | | 113 | Elf_Addr relasz = 0; |
114 | Elf_Addr *where; | | 114 | Elf_Addr *where; |
115 | | | 115 | |
116 | for (; dynp->d_tag != DT_NULL; dynp++) { | | 116 | for (; dynp->d_tag != DT_NULL; dynp++) { |
117 | switch (dynp->d_tag) { | | 117 | switch (dynp->d_tag) { |
118 | case DT_RELA: | | 118 | case DT_RELA: |
119 | rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr); | | 119 | rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr); |
120 | break; | | 120 | break; |
121 | case DT_RELASZ: | | 121 | case DT_RELASZ: |
122 | relasz = dynp->d_un.d_val; | | 122 | relasz = dynp->d_un.d_val; |
123 | break; | | 123 | break; |
124 | } | | 124 | } |
125 | } | | 125 | } |
126 | relalim = (const Elf_Rela *)((caddr_t)rela + relasz); | | 126 | relalim = (const Elf_Rela *)((const uint8_t *)rela + relasz); |
127 | for (; rela < relalim; rela++) { | | 127 | for (; rela < relalim; rela++) { |
128 | where = (Elf_Addr *)(relocbase + rela->r_offset); | | 128 | where = (Elf_Addr *)(relocbase + rela->r_offset); |
129 | *where = (Elf_Addr)(relocbase + rela->r_addend); | | 129 | *where = (Elf_Addr)(relocbase + rela->r_addend); |
130 | } | | 130 | } |
131 | } | | 131 | } |
132 | | | 132 | |
133 | int | | 133 | int |
134 | _rtld_relocate_nonplt_objects(const Obj_Entry *obj) | | 134 | _rtld_relocate_nonplt_objects(const Obj_Entry *obj) |
135 | { | | 135 | { |
136 | const Elf_Rela *rela; | | 136 | const Elf_Rela *rela; |
137 | | | 137 | |
138 | for (rela = obj->rela; rela < obj->relalim; rela++) { | | 138 | for (rela = obj->rela; rela < obj->relalim; rela++) { |
139 | Elf_Addr *where; | | 139 | Elf_Addr *where; |