Deleted Added
full compact
reloc.c (204211) reloc.c (208256)
1/* $NetBSD: ppc_reloc.c,v 1.10 2001/09/10 06:09:41 mycroft Exp $ */
2
3/*-
4 * Copyright (C) 1998 Tsubai Masanari
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
1/* $NetBSD: ppc_reloc.c,v 1.10 2001/09/10 06:09:41 mycroft Exp $ */
2
3/*-
4 * Copyright (C) 1998 Tsubai Masanari
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * $FreeBSD: head/libexec/rtld-elf/powerpc/reloc.c 204211 2010-02-22 16:49:45Z nwhitehorn $
29 * $FreeBSD: head/libexec/rtld-elf/powerpc/reloc.c 208256 2010-05-18 08:55:23Z rdivacky $
30 */
31
32#include <sys/param.h>
33#include <sys/mman.h>
34
35#include <errno.h>
36#include <stdio.h>
37#include <stdlib.h>

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

282 * Process non-PLT relocations
283 */
284int
285reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
286{
287 const Elf_Rela *relalim;
288 const Elf_Rela *rela;
289 SymCache *cache;
30 */
31
32#include <sys/param.h>
33#include <sys/mman.h>
34
35#include <errno.h>
36#include <stdio.h>
37#include <stdlib.h>

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

282 * Process non-PLT relocations
283 */
284int
285reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
286{
287 const Elf_Rela *relalim;
288 const Elf_Rela *rela;
289 SymCache *cache;
290 int bytes = obj->nchains * sizeof(SymCache);
291 int r = -1;
292
293 /*
294 * The dynamic loader may be called from a thread, we have
295 * limited amounts of stack available so we cannot use alloca().
296 */
297 if (obj != obj_rtld) {
290 int r = -1;
291
292 /*
293 * The dynamic loader may be called from a thread, we have
294 * limited amounts of stack available so we cannot use alloca().
295 */
296 if (obj != obj_rtld) {
298 cache = mmap(NULL, bytes, PROT_READ|PROT_WRITE, MAP_ANON,
299 -1, 0);
300 if (cache == MAP_FAILED)
301 cache = NULL;
297 cache = calloc(obj->nchains, sizeof(SymCache));
298 /* No need to check for NULL here */
302 } else
303 cache = NULL;
304
305 /*
306 * From the SVR4 PPC ABI:
307 * "The PowerPC family uses only the Elf32_Rela relocation
308 * entries with explicit addends."
309 */
310 relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
311 for (rela = obj->rela; rela < relalim; rela++) {
312 if (reloc_nonplt_object(obj_rtld, obj, rela, cache) < 0)
313 goto done;
314 }
315 r = 0;
316done:
299 } else
300 cache = NULL;
301
302 /*
303 * From the SVR4 PPC ABI:
304 * "The PowerPC family uses only the Elf32_Rela relocation
305 * entries with explicit addends."
306 */
307 relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
308 for (rela = obj->rela; rela < relalim; rela++) {
309 if (reloc_nonplt_object(obj_rtld, obj, rela, cache) < 0)
310 goto done;
311 }
312 r = 0;
313done:
317 if (cache) {
318 munmap(cache, bytes);
319 }
314 if (cache != NULL)
315 free(cache);
320 return (r);
321}
322
323/*
324 * Initialise a PLT slot to the resolving trampoline
325 */
326static int
327reloc_plt_object(Obj_Entry *obj, const Elf_Rela *rela)

--- 294 unchanged lines hidden ---
316 return (r);
317}
318
319/*
320 * Initialise a PLT slot to the resolving trampoline
321 */
322static int
323reloc_plt_object(Obj_Entry *obj, const Elf_Rela *rela)

--- 294 unchanged lines hidden ---