map_object.c (230784) | map_object.c (232831) |
---|---|
1/*- 2 * Copyright 1996-1998 John D. Polstra. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 8 unchanged lines hidden (view full) --- 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * | 1/*- 2 * Copyright 1996-1998 John D. Polstra. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 8 unchanged lines hidden (view full) --- 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * |
25 * $FreeBSD: head/libexec/rtld-elf/map_object.c 230784 2012-01-30 19:52:17Z kib $ | 25 * $FreeBSD: head/libexec/rtld-elf/map_object.c 232831 2012-03-11 20:03:09Z kib $ |
26 */ 27 28#include <sys/param.h> 29#include <sys/mman.h> 30#include <sys/stat.h> 31 32#include <errno.h> 33#include <stddef.h> --- 47 unchanged lines hidden (view full) --- 81 Elf_Addr phdr_vaddr; 82 size_t nclear, phsize; 83 Elf_Addr bss_vaddr; 84 Elf_Addr bss_vlimit; 85 caddr_t bss_addr; 86 Elf_Word stack_flags; 87 Elf_Addr relro_page; 88 size_t relro_size; | 26 */ 27 28#include <sys/param.h> 29#include <sys/mman.h> 30#include <sys/stat.h> 31 32#include <errno.h> 33#include <stddef.h> --- 47 unchanged lines hidden (view full) --- 81 Elf_Addr phdr_vaddr; 82 size_t nclear, phsize; 83 Elf_Addr bss_vaddr; 84 Elf_Addr bss_vlimit; 85 caddr_t bss_addr; 86 Elf_Word stack_flags; 87 Elf_Addr relro_page; 88 size_t relro_size; |
89 Elf_Addr note_start; 90 Elf_Addr note_end; |
|
89 90 hdr = get_elf_header(fd, path); 91 if (hdr == NULL) 92 return (NULL); 93 94 /* 95 * Scan the program header entries, and save key information. 96 * 97 * We expect that the loadable segments are ordered by load address. 98 */ 99 phdr = (Elf_Phdr *) ((char *)hdr + hdr->e_phoff); 100 phsize = hdr->e_phnum * sizeof (phdr[0]); 101 phlimit = phdr + hdr->e_phnum; 102 nsegs = -1; 103 phdyn = phinterp = phtls = NULL; 104 phdr_vaddr = 0; 105 relro_page = 0; 106 relro_size = 0; | 91 92 hdr = get_elf_header(fd, path); 93 if (hdr == NULL) 94 return (NULL); 95 96 /* 97 * Scan the program header entries, and save key information. 98 * 99 * We expect that the loadable segments are ordered by load address. 100 */ 101 phdr = (Elf_Phdr *) ((char *)hdr + hdr->e_phoff); 102 phsize = hdr->e_phnum * sizeof (phdr[0]); 103 phlimit = phdr + hdr->e_phnum; 104 nsegs = -1; 105 phdyn = phinterp = phtls = NULL; 106 phdr_vaddr = 0; 107 relro_page = 0; 108 relro_size = 0; |
109 note_start = 0; 110 note_end = 0; |
|
107 segs = alloca(sizeof(segs[0]) * hdr->e_phnum); 108 stack_flags = RTLD_DEFAULT_STACK_PF_EXEC | PF_R | PF_W; 109 while (phdr < phlimit) { 110 switch (phdr->p_type) { 111 112 case PT_INTERP: 113 phinterp = phdr; 114 break; --- 23 unchanged lines hidden (view full) --- 138 case PT_GNU_STACK: 139 stack_flags = phdr->p_flags; 140 break; 141 142 case PT_GNU_RELRO: 143 relro_page = phdr->p_vaddr; 144 relro_size = phdr->p_memsz; 145 break; | 111 segs = alloca(sizeof(segs[0]) * hdr->e_phnum); 112 stack_flags = RTLD_DEFAULT_STACK_PF_EXEC | PF_R | PF_W; 113 while (phdr < phlimit) { 114 switch (phdr->p_type) { 115 116 case PT_INTERP: 117 phinterp = phdr; 118 break; --- 23 unchanged lines hidden (view full) --- 142 case PT_GNU_STACK: 143 stack_flags = phdr->p_flags; 144 break; 145 146 case PT_GNU_RELRO: 147 relro_page = phdr->p_vaddr; 148 relro_size = phdr->p_memsz; 149 break; |
150 151 case PT_NOTE: 152 note_start = (Elf_Addr)obj->relocbase + phdr->p_offset; 153 note_end = note_start + phdr->p_filesz; 154 digest_notes(obj, note_start, note_end); 155 break; |
|
146 } 147 148 ++phdr; 149 } 150 if (phdyn == NULL) { 151 _rtld_error("%s: object is not dynamically-linked", path); 152 return NULL; 153 } --- 273 unchanged lines hidden --- | 156 } 157 158 ++phdr; 159 } 160 if (phdyn == NULL) { 161 _rtld_error("%s: object is not dynamically-linked", path); 162 return NULL; 163 } --- 273 unchanged lines hidden --- |