libelf_phdr.c (165535) | libelf_phdr.c (210338) |
---|---|
1/*- 2 * Copyright (c) 2006 Joseph Koshy 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2006 Joseph Koshy 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/lib/libelf/libelf_phdr.c 165535 2006-12-25 02:22:22Z jkoshy $ | 26 * $FreeBSD: head/lib/libelf/libelf_phdr.c 210338 2010-07-21 10:25:02Z kaiw $ |
27 */ 28 29#include <sys/cdefs.h> | 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/lib/libelf/libelf_phdr.c 165535 2006-12-25 02:22:22Z jkoshy $"); | 30__FBSDID("$FreeBSD: head/lib/libelf/libelf_phdr.c 210338 2010-07-21 10:25:02Z kaiw $"); |
31 32#include <assert.h> 33#include <gelf.h> 34#include <libelf.h> 35#include <stdlib.h> 36 37#include "_libelf.h" 38 39void * 40_libelf_getphdr(Elf *e, int ec) 41{ 42 size_t phnum, phentsize; 43 size_t fsz, msz; 44 uint64_t phoff; 45 Elf32_Ehdr *eh32; 46 Elf64_Ehdr *eh64; 47 void *ehdr, *phdr; | 31 32#include <assert.h> 33#include <gelf.h> 34#include <libelf.h> 35#include <stdlib.h> 36 37#include "_libelf.h" 38 39void * 40_libelf_getphdr(Elf *e, int ec) 41{ 42 size_t phnum, phentsize; 43 size_t fsz, msz; 44 uint64_t phoff; 45 Elf32_Ehdr *eh32; 46 Elf64_Ehdr *eh64; 47 void *ehdr, *phdr; |
48 void (*xlator)(char *_d, char *_s, size_t _c, int _swap); | 48 int (*xlator)(char *_d, size_t _dsz, char *_s, size_t _c, int _swap); |
49 50 assert(ec == ELFCLASS32 || ec == ELFCLASS64); 51 52 if (e == NULL) { 53 LIBELF_SET_ERROR(ARGUMENT, 0); 54 return (NULL); 55 } 56 --- 41 unchanged lines hidden (view full) --- 98 99 if (ec == ELFCLASS32) 100 e->e_u.e_elf.e_phdr.e_phdr32 = phdr; 101 else 102 e->e_u.e_elf.e_phdr.e_phdr64 = phdr; 103 104 105 xlator = _libelf_get_translator(ELF_T_PHDR, ELF_TOMEMORY, ec); | 49 50 assert(ec == ELFCLASS32 || ec == ELFCLASS64); 51 52 if (e == NULL) { 53 LIBELF_SET_ERROR(ARGUMENT, 0); 54 return (NULL); 55 } 56 --- 41 unchanged lines hidden (view full) --- 98 99 if (ec == ELFCLASS32) 100 e->e_u.e_elf.e_phdr.e_phdr32 = phdr; 101 else 102 e->e_u.e_elf.e_phdr.e_phdr64 = phdr; 103 104 105 xlator = _libelf_get_translator(ELF_T_PHDR, ELF_TOMEMORY, ec); |
106 (*xlator)(phdr, e->e_rawfile + phoff, phnum, | 106 (*xlator)(phdr, phnum * msz, e->e_rawfile + phoff, phnum, |
107 e->e_byteorder != LIBELF_PRIVATE(byteorder)); 108 109 return (phdr); 110} 111 112void * 113_libelf_newphdr(Elf *e, int ec, size_t count) 114{ --- 43 unchanged lines hidden --- | 107 e->e_byteorder != LIBELF_PRIVATE(byteorder)); 108 109 return (phdr); 110} 111 112void * 113_libelf_newphdr(Elf *e, int ec, size_t count) 114{ --- 43 unchanged lines hidden --- |