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/amd64/reloc.c 157198 2006-03-28 06:09:24Z davidxu $
25 * $FreeBSD: head/libexec/rtld-elf/amd64/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

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

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

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

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

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

317 _rtld_error("%s: Unsupported relocation type %u"
318 " in non-PLT relocations\n", obj->path,
319 (unsigned int)ELF_R_TYPE(rela->r_info));
320 goto done;
321 }
322 }
323 r = 0;
324done:
131 cache = NULL;
132
133 relalim = (const Elf_Rela *) ((caddr_t) obj->rela + obj->relasize);
134 for (rela = obj->rela; rela < relalim; rela++) {
135 Elf_Addr *where = (Elf_Addr *) (obj->relocbase + rela->r_offset);
136 Elf32_Addr *where32 = (Elf32_Addr *)where;
137
138 switch (ELF_R_TYPE(rela->r_info)) {

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

318 _rtld_error("%s: Unsupported relocation type %u"
319 " in non-PLT relocations\n", obj->path,
320 (unsigned int)ELF_R_TYPE(rela->r_info));
321 goto done;
322 }
323 }
324 r = 0;
325done:
325 if (cache)
326 munmap(cache, bytes);
326 if (cache != NULL)
327 free(cache);
327 return(r);
328}
329
330/* Process the PLT relocations. */
331int
332reloc_plt(Obj_Entry *obj)
333{
334 const Elf_Rela *relalim;

--- 65 unchanged lines hidden ---
328 return(r);
329}
330
331/* Process the PLT relocations. */
332int
333reloc_plt(Obj_Entry *obj)
334{
335 const Elf_Rela *relalim;

--- 65 unchanged lines hidden ---