reloc.c (153515) | reloc.c (208256) |
---|---|
1/* $NetBSD: mdreloc.c,v 1.23 2003/07/26 15:04:38 mrg Exp $ */ 2 3#include <sys/cdefs.h> | 1/* $NetBSD: mdreloc.c,v 1.23 2003/07/26 15:04:38 mrg Exp $ */ 2 3#include <sys/cdefs.h> |
4__FBSDID("$FreeBSD: head/libexec/rtld-elf/arm/reloc.c 153515 2005-12-18 19:43:33Z kan $"); | 4__FBSDID("$FreeBSD: head/libexec/rtld-elf/arm/reloc.c 208256 2010-05-18 08:55:23Z rdivacky $"); |
5#include <sys/param.h> 6#include <sys/mman.h> 7 8#include <errno.h> 9#include <stdio.h> 10#include <stdlib.h> 11#include <string.h> 12#include <unistd.h> --- 227 unchanged lines hidden (view full) --- 240 * * Process non-PLT relocations 241 * */ 242int 243reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld) 244{ 245 const Elf_Rel *rellim; 246 const Elf_Rel *rel; 247 SymCache *cache; | 5#include <sys/param.h> 6#include <sys/mman.h> 7 8#include <errno.h> 9#include <stdio.h> 10#include <stdlib.h> 11#include <string.h> 12#include <unistd.h> --- 227 unchanged lines hidden (view full) --- 240 * * Process non-PLT relocations 241 * */ 242int 243reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld) 244{ 245 const Elf_Rel *rellim; 246 const Elf_Rel *rel; 247 SymCache *cache; |
248 int bytes = obj->nchains * sizeof(SymCache); | |
249 int r = -1; 250 251 /* The relocation for the dynamic loader has already been done. */ 252 if (obj == obj_rtld) 253 return (0); 254 /* 255 * The dynamic loader may be called from a thread, we have 256 * limited amounts of stack available so we cannot use alloca(). 257 */ | 248 int r = -1; 249 250 /* The relocation for the dynamic loader has already been done. */ 251 if (obj == obj_rtld) 252 return (0); 253 /* 254 * The dynamic loader may be called from a thread, we have 255 * limited amounts of stack available so we cannot use alloca(). 256 */ |
258 cache = mmap(NULL, bytes, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); 259 if (cache == MAP_FAILED) 260 cache = NULL; 261 | 257 cache = calloc(obj->nchains, sizeof(SymCache)); 258 /* No need to check for NULL here */ 259 |
262 rellim = (const Elf_Rel *)((caddr_t)obj->rel + obj->relsize); 263 for (rel = obj->rel; rel < rellim; rel++) { 264 if (reloc_nonplt_object(obj, rel, cache) < 0) 265 goto done; 266 } 267 r = 0; 268done: | 260 rellim = (const Elf_Rel *)((caddr_t)obj->rel + obj->relsize); 261 for (rel = obj->rel; rel < rellim; rel++) { 262 if (reloc_nonplt_object(obj, rel, cache) < 0) 263 goto done; 264 } 265 r = 0; 266done: |
269 if (cache) { 270 munmap(cache, bytes); 271 } | 267 if (cache != NULL) 268 free(cache); |
272 return (r); 273} 274 275/* 276 * * Process the PLT relocations. 277 * */ 278int 279reloc_plt(Obj_Entry *obj) --- 76 unchanged lines hidden --- | 269 return (r); 270} 271 272/* 273 * * Process the PLT relocations. 274 * */ 275int 276reloc_plt(Obj_Entry *obj) --- 76 unchanged lines hidden --- |