Deleted Added
full compact
reloc.c (56780) reloc.c (76296)
1/*-
2 * Copyright 1996, 1997, 1998, 1999 John D. Polstra.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
1/*-
2 * Copyright 1996, 1997, 1998, 1999 John D. Polstra.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * $FreeBSD: head/libexec/rtld-elf/i386/reloc.c 56780 2000-01-29 01:27:04Z jdp $
25 * $FreeBSD: head/libexec/rtld-elf/i386/reloc.c 76296 2001-05-05 23:21:05Z jdp $
26 */
27
28/*
29 * Dynamic linker for ELF.
30 *
31 * John Polstra <jdp@polstra.com>.
32 */
33

--- 75 unchanged lines hidden (view full) ---

109}
110
111/* Process the non-PLT relocations. */
112int
113reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
114{
115 const Elf_Rel *rellim;
116 const Elf_Rel *rel;
26 */
27
28/*
29 * Dynamic linker for ELF.
30 *
31 * John Polstra <jdp@polstra.com>.
32 */
33

--- 75 unchanged lines hidden (view full) ---

109}
110
111/* Process the non-PLT relocations. */
112int
113reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
114{
115 const Elf_Rel *rellim;
116 const Elf_Rel *rel;
117 SymCache *cache;
117
118
119 cache = (SymCache *)alloca(obj->nchains * sizeof(SymCache));
120 if (cache != NULL)
121 memset(cache, 0, obj->nchains * sizeof(SymCache));
122
118 rellim = (const Elf_Rel *) ((caddr_t) obj->rel + obj->relsize);
119 for (rel = obj->rel; rel < rellim; rel++) {
120 Elf_Addr *where = (Elf_Addr *) (obj->relocbase + rel->r_offset);
121
122 switch (ELF_R_TYPE(rel->r_info)) {
123
124 case R_386_NONE:
125 break;
126
127 case R_386_32:
128 {
129 const Elf_Sym *def;
130 const Obj_Entry *defobj;
131
132 def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj,
123 rellim = (const Elf_Rel *) ((caddr_t) obj->rel + obj->relsize);
124 for (rel = obj->rel; rel < rellim; rel++) {
125 Elf_Addr *where = (Elf_Addr *) (obj->relocbase + rel->r_offset);
126
127 switch (ELF_R_TYPE(rel->r_info)) {
128
129 case R_386_NONE:
130 break;
131
132 case R_386_32:
133 {
134 const Elf_Sym *def;
135 const Obj_Entry *defobj;
136
137 def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj,
133 false);
138 false, cache);
134 if (def == NULL)
135 return -1;
136
137 *where += (Elf_Addr) (defobj->relocbase + def->st_value);
138 }
139 break;
140
141 case R_386_PC32:
142 /*
143 * I don't think the dynamic linker should ever see this
144 * type of relocation. But the binutils-2.6 tools sometimes
145 * generate it.
146 */
147 {
148 const Elf_Sym *def;
149 const Obj_Entry *defobj;
150
151 def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj,
139 if (def == NULL)
140 return -1;
141
142 *where += (Elf_Addr) (defobj->relocbase + def->st_value);
143 }
144 break;
145
146 case R_386_PC32:
147 /*
148 * I don't think the dynamic linker should ever see this
149 * type of relocation. But the binutils-2.6 tools sometimes
150 * generate it.
151 */
152 {
153 const Elf_Sym *def;
154 const Obj_Entry *defobj;
155
156 def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj,
152 false);
157 false, cache);
153 if (def == NULL)
154 return -1;
155
156 *where +=
157 (Elf_Addr) (defobj->relocbase + def->st_value) -
158 (Elf_Addr) where;
159 }
160 break;

--- 13 unchanged lines hidden (view full) ---

174 break;
175
176 case R_386_GLOB_DAT:
177 {
178 const Elf_Sym *def;
179 const Obj_Entry *defobj;
180
181 def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj,
158 if (def == NULL)
159 return -1;
160
161 *where +=
162 (Elf_Addr) (defobj->relocbase + def->st_value) -
163 (Elf_Addr) where;
164 }
165 break;

--- 13 unchanged lines hidden (view full) ---

179 break;
180
181 case R_386_GLOB_DAT:
182 {
183 const Elf_Sym *def;
184 const Obj_Entry *defobj;
185
186 def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj,
182 false);
187 false, cache);
183 if (def == NULL)
184 return -1;
185
186 *where = (Elf_Addr) (defobj->relocbase + def->st_value);
187 }
188 break;
189
190 case R_386_RELATIVE:

--- 42 unchanged lines hidden (view full) ---

233 rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
234 for (rel = obj->pltrel; rel < rellim; rel++) {
235 Elf_Addr *where;
236 const Elf_Sym *def;
237 const Obj_Entry *defobj;
238
239 assert(ELF_R_TYPE(rel->r_info) == R_386_JMP_SLOT);
240 where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
188 if (def == NULL)
189 return -1;
190
191 *where = (Elf_Addr) (defobj->relocbase + def->st_value);
192 }
193 break;
194
195 case R_386_RELATIVE:

--- 42 unchanged lines hidden (view full) ---

238 rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
239 for (rel = obj->pltrel; rel < rellim; rel++) {
240 Elf_Addr *where;
241 const Elf_Sym *def;
242 const Obj_Entry *defobj;
243
244 assert(ELF_R_TYPE(rel->r_info) == R_386_JMP_SLOT);
245 where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
241 def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, true);
246 def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, true, NULL);
242 if (def == NULL)
243 return -1;
244 reloc_jmpslot(where, (Elf_Addr)(defobj->relocbase + def->st_value));
245 }
246 obj->jmpslots_done = true;
247 return 0;
248}
247 if (def == NULL)
248 return -1;
249 reloc_jmpslot(where, (Elf_Addr)(defobj->relocbase + def->st_value));
250 }
251 obj->jmpslots_done = true;
252 return 0;
253}