Thu Sep 30 19:45:25 2010 UTC ()
Oops. Remove trailing whitespace in previous.


(skrll)
diff -r1.32 -r1.33 src/libexec/ld.elf_so/headers.c

cvs diff -r1.32 -r1.33 src/libexec/ld.elf_so/headers.c (expand / switch to unified diff)

--- src/libexec/ld.elf_so/headers.c 2010/09/30 19:43:11 1.32
+++ src/libexec/ld.elf_so/headers.c 2010/09/30 19:45:24 1.33
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: headers.c,v 1.32 2010/09/30 19:43:11 skrll Exp $ */ 1/* $NetBSD: headers.c,v 1.33 2010/09/30 19:45:24 skrll Exp $ */
2 2
3/* 3/*
4 * Copyright 1996 John D. Polstra. 4 * Copyright 1996 John D. Polstra.
5 * Copyright 1996 Matt Thomas <matt@3am-software.com> 5 * Copyright 1996 Matt Thomas <matt@3am-software.com>
6 * Copyright 2002 Charles M. Hannum <root@ihack.net> 6 * Copyright 2002 Charles M. Hannum <root@ihack.net>
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -30,27 +30,27 @@ @@ -30,27 +30,27 @@
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35/* 35/*
36 * Dynamic linker for ELF. 36 * Dynamic linker for ELF.
37 * 37 *
38 * John Polstra <jdp@polstra.com>. 38 * John Polstra <jdp@polstra.com>.
39 */ 39 */
40 40
41#include <sys/cdefs.h> 41#include <sys/cdefs.h>
42#ifndef lint 42#ifndef lint
43__RCSID("$NetBSD: headers.c,v 1.32 2010/09/30 19:43:11 skrll Exp $"); 43__RCSID("$NetBSD: headers.c,v 1.33 2010/09/30 19:45:24 skrll Exp $");
44#endif /* not lint */ 44#endif /* not lint */
45 45
46#include <err.h> 46#include <err.h>
47#include <errno.h> 47#include <errno.h>
48#include <fcntl.h> 48#include <fcntl.h>
49#include <stdarg.h> 49#include <stdarg.h>
50#include <stdio.h> 50#include <stdio.h>
51#include <stdlib.h> 51#include <stdlib.h>
52#include <string.h> 52#include <string.h>
53#include <unistd.h> 53#include <unistd.h>
54#include <sys/types.h> 54#include <sys/types.h>
55#include <sys/mman.h> 55#include <sys/mman.h>
56#include <sys/bitops.h> 56#include <sys/bitops.h>
@@ -307,28 +307,28 @@ _rtld_digest_phdr(const Elf_Phdr *phdr,  @@ -307,28 +307,28 @@ _rtld_digest_phdr(const Elf_Phdr *phdr,
307 const Elf_Phdr *phlimit = phdr + phnum; 307 const Elf_Phdr *phlimit = phdr + phnum;
308 const Elf_Phdr *ph; 308 const Elf_Phdr *ph;
309 int nsegs = 0; 309 int nsegs = 0;
310 ptrdiff_t relocoffs = 0; 310 ptrdiff_t relocoffs = 0;
311 Elf_Addr vaddr; 311 Elf_Addr vaddr;
312 312
313 obj = _rtld_obj_new(); 313 obj = _rtld_obj_new();
314 for (ph = phdr; ph < phlimit; ++ph) { 314 for (ph = phdr; ph < phlimit; ++ph) {
315 vaddr = ph->p_vaddr + relocoffs; 315 vaddr = ph->p_vaddr + relocoffs;
316 switch (ph->p_type) { 316 switch (ph->p_type) {
317 317
318 case PT_PHDR: 318 case PT_PHDR:
319 relocoffs = (uintptr_t)phdr - (uintptr_t)ph->p_vaddr; 319 relocoffs = (uintptr_t)phdr - (uintptr_t)ph->p_vaddr;
320 dbg(("headers: phdr %p phsize %zu relocoffs %lx", obj->phdr,  320 dbg(("headers: phdr %p phsize %zu relocoffs %lx", obj->phdr,
321 obj->phsize, (long)relocoffs));  321 obj->phsize, (long)relocoffs));
322 break; 322 break;
323 323
324 case PT_INTERP: 324 case PT_INTERP:
325 obj->interp = (const char *)(uintptr_t)vaddr; 325 obj->interp = (const char *)(uintptr_t)vaddr;
326 break; 326 break;
327 327
328 case PT_LOAD: 328 case PT_LOAD:
329 assert(nsegs < 2); 329 assert(nsegs < 2);
330 if (nsegs == 0) { /* First load segment */ 330 if (nsegs == 0) { /* First load segment */
331 obj->vaddrbase = round_down(vaddr); 331 obj->vaddrbase = round_down(vaddr);
332 obj->mapbase = (caddr_t)(uintptr_t)obj->vaddrbase; 332 obj->mapbase = (caddr_t)(uintptr_t)obj->vaddrbase;
333 obj->relocbase = (void *)relocoffs; 333 obj->relocbase = (void *)relocoffs;
334 obj->textsize = round_up(vaddr + ph->p_memsz) - 334 obj->textsize = round_up(vaddr + ph->p_memsz) -