Deleted Added
full compact
reloc.c (172708) reloc.c (208256)
1/* $NetBSD: mdreloc.c,v 1.5 2001/04/25 12:24:51 kleink Exp $ */
2
3/*-
4 * Copyright (c) 2000 Eduardo Horvath.
5 * Copyright (c) 1999 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation

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

33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40#include <sys/cdefs.h>
1/* $NetBSD: mdreloc.c,v 1.5 2001/04/25 12:24:51 kleink Exp $ */
2
3/*-
4 * Copyright (c) 2000 Eduardo Horvath.
5 * Copyright (c) 1999 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation

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

33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40#include <sys/cdefs.h>
41__FBSDID("$FreeBSD: head/libexec/rtld-elf/sparc64/reloc.c 172708 2007-10-16 19:17:48Z marius $");
41__FBSDID("$FreeBSD: head/libexec/rtld-elf/sparc64/reloc.c 208256 2010-05-18 08:55:23Z rdivacky $");
42
43#include <sys/param.h>
44#include <sys/mman.h>
45
46#include <errno.h>
47#include <stdio.h>
48#include <stdlib.h>
49#include <string.h>

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

249}
250
251int
252reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
253{
254 const Elf_Rela *relalim;
255 const Elf_Rela *rela;
256 SymCache *cache;
42
43#include <sys/param.h>
44#include <sys/mman.h>
45
46#include <errno.h>
47#include <stdio.h>
48#include <stdlib.h>
49#include <string.h>

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

249}
250
251int
252reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
253{
254 const Elf_Rela *relalim;
255 const Elf_Rela *rela;
256 SymCache *cache;
257 int bytes = obj->nchains * sizeof(SymCache);
258 int r = -1;
259
260 /*
261 * The dynamic loader may be called from a thread, we have
262 * limited amounts of stack available so we cannot use alloca().
263 */
264 if (obj != obj_rtld) {
257 int r = -1;
258
259 /*
260 * The dynamic loader may be called from a thread, we have
261 * limited amounts of stack available so we cannot use alloca().
262 */
263 if (obj != obj_rtld) {
265 cache = mmap(NULL, bytes, PROT_READ|PROT_WRITE, MAP_ANON,
266 -1, 0);
267 if (cache == MAP_FAILED)
268 cache = NULL;
264 cache = calloc(obj->nchains, sizeof(SymCache));
265 /* No need to check for NULL here */
269 } else
270 cache = NULL;
271
272 relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
273 for (rela = obj->rela; rela < relalim; rela++) {
274 if (reloc_nonplt_object(obj, rela, cache) < 0)
275 goto done;
276 }
277 r = 0;
278done:
266 } else
267 cache = NULL;
268
269 relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
270 for (rela = obj->rela; rela < relalim; rela++) {
271 if (reloc_nonplt_object(obj, rela, cache) < 0)
272 goto done;
273 }
274 r = 0;
275done:
279 if (cache)
280 munmap(cache, bytes);
276 if (cache != NULL)
277 free(cache);
281 return (r);
282}
283
284static int
285reloc_nonplt_object(Obj_Entry *obj, const Elf_Rela *rela, SymCache *cache)
286{
287 const Obj_Entry *defobj;
288 const Elf_Sym *def;

--- 464 unchanged lines hidden ---
278 return (r);
279}
280
281static int
282reloc_nonplt_object(Obj_Entry *obj, const Elf_Rela *rela, SymCache *cache)
283{
284 const Obj_Entry *defobj;
285 const Elf_Sym *def;

--- 464 unchanged lines hidden ---