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 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; |
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) { |
297 cache = calloc(obj->nchains, sizeof(SymCache)); 298 /* No need to check for NULL here */ |
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: |
314 if (cache != NULL) 315 free(cache); |
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 --- |