Deleted Added
full compact
reloc.c (157198) reloc.c (208256)
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 157198 2006-03-28 06:09:24Z davidxu $
25 * $FreeBSD: head/libexec/rtld-elf/i386/reloc.c 208256 2010-05-18 08:55:23Z rdivacky $
26 */
27
28/*
29 * Dynamic linker for ELF.
30 *
31 * John Polstra <jdp@polstra.com>.
32 */
33

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

114
115/* Process the non-PLT relocations. */
116int
117reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
118{
119 const Elf_Rel *rellim;
120 const Elf_Rel *rel;
121 SymCache *cache;
26 */
27
28/*
29 * Dynamic linker for ELF.
30 *
31 * John Polstra <jdp@polstra.com>.
32 */
33

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

114
115/* Process the non-PLT relocations. */
116int
117reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
118{
119 const Elf_Rel *rellim;
120 const Elf_Rel *rel;
121 SymCache *cache;
122 int bytes = obj->nchains * sizeof(SymCache);
123 int r = -1;
124
125 /*
126 * The dynamic loader may be called from a thread, we have
127 * limited amounts of stack available so we cannot use alloca().
128 */
122 int r = -1;
123
124 /*
125 * The dynamic loader may be called from a thread, we have
126 * limited amounts of stack available so we cannot use alloca().
127 */
129 cache = mmap(NULL, bytes, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0);
130 if (cache == MAP_FAILED)
128 if (obj != obj_rtld) {
129 cache = calloc(obj->nchains, sizeof(SymCache));
130 /* No need to check for NULL here */
131 } else
131 cache = NULL;
132
133 rellim = (const Elf_Rel *) ((caddr_t) obj->rel + obj->relsize);
134 for (rel = obj->rel; rel < rellim; rel++) {
135 Elf_Addr *where = (Elf_Addr *) (obj->relocbase + rel->r_offset);
136
137 switch (ELF_R_TYPE(rel->r_info)) {
138

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

268 _rtld_error("%s: Unsupported relocation type %d"
269 " in non-PLT relocations\n", obj->path,
270 ELF_R_TYPE(rel->r_info));
271 goto done;
272 }
273 }
274 r = 0;
275done:
132 cache = NULL;
133
134 rellim = (const Elf_Rel *) ((caddr_t) obj->rel + obj->relsize);
135 for (rel = obj->rel; rel < rellim; rel++) {
136 Elf_Addr *where = (Elf_Addr *) (obj->relocbase + rel->r_offset);
137
138 switch (ELF_R_TYPE(rel->r_info)) {
139

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

269 _rtld_error("%s: Unsupported relocation type %d"
270 " in non-PLT relocations\n", obj->path,
271 ELF_R_TYPE(rel->r_info));
272 goto done;
273 }
274 }
275 r = 0;
276done:
276 if (cache)
277 munmap(cache, bytes);
277 if (cache != NULL)
278 free(cache);
278 return(r);
279}
280
281/* Process the PLT relocations. */
282int
283reloc_plt(Obj_Entry *obj)
284{
285 const Elf_Rel *rellim;

--- 81 unchanged lines hidden ---
279 return(r);
280}
281
282/* Process the PLT relocations. */
283int
284reloc_plt(Obj_Entry *obj)
285{
286 const Elf_Rel *rellim;

--- 81 unchanged lines hidden ---