libelf_fsize.m4 (210332) | libelf_fsize.m4 (210335) |
---|---|
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_fsize.m4 210332 2010-07-21 09:56:42Z kaiw $ | 26 * $FreeBSD: head/lib/libelf/libelf_fsize.m4 210335 2010-07-21 10:08:25Z kaiw $ |
27 */ 28 29#include <libelf.h> 30#include <osreldate.h> 31 32#include "_libelf.h" 33 34/* 35 * Create an array of file sizes from the elf_type definitions 36 */ 37 38divert(-1) 39include(SRCDIR`/elf_types.m4') 40 41/* 42 * Translations from structure definitions to the size of their file 43 * representations. 44 */ 45 | 27 */ 28 29#include <libelf.h> 30#include <osreldate.h> 31 32#include "_libelf.h" 33 34/* 35 * Create an array of file sizes from the elf_type definitions 36 */ 37 38divert(-1) 39include(SRCDIR`/elf_types.m4') 40 41/* 42 * Translations from structure definitions to the size of their file 43 * representations. 44 */ 45 |
46/* `Basic' types */ | 46/* `Basic' types. */ |
47define(`BYTE_SIZE', 1) | 47define(`BYTE_SIZE', 1) |
48define(`GNUHASH_SIZE', 1) /* Elf_GNU_Hash_Header structures vary in length. */ | |
49define(`IDENT_SIZE', `EI_NIDENT') | 48define(`IDENT_SIZE', `EI_NIDENT') |
50define(`NOTE_SIZE', 1) /* Elf_Note structures have variable length. */ | |
51 | 49 |
52/* Currently unimplemented types */ | 50/* Types that have variable length. */ 51define(`GNUHASH_SIZE', 0) /* Elf_GNU_Hash_Header structures vary in length. */ 52define(`NOTE_SIZE', 0) /* Elf_Note structures have variable length. */ 53 54/* Currently unimplemented types. */ |
53define(`MOVEP_SIZE', 0) 54 | 55define(`MOVEP_SIZE', 0) 56 |
55/* Overrides for 32 bit types that do not exist */ | 57/* Overrides for 32 bit types that do not exist. */ |
56define(`XWORD_SIZE32', 0) 57define(`SXWORD_SIZE32', 0) 58 59/* 60 * FSZ{32,64} define the sizes of 32 and 64 bit file structures respectively. 61 */ 62 63define(`FSZ32',`_FSZ32($1_DEF)') --- 74 unchanged lines hidden (view full) --- 138size_t 139_libelf_fsize(Elf_Type t, int ec, unsigned int v, size_t c) 140{ 141 size_t sz; 142 143 sz = 0; 144 if (v != EV_CURRENT) 145 LIBELF_SET_ERROR(VERSION, 0); | 58define(`XWORD_SIZE32', 0) 59define(`SXWORD_SIZE32', 0) 60 61/* 62 * FSZ{32,64} define the sizes of 32 and 64 bit file structures respectively. 63 */ 64 65define(`FSZ32',`_FSZ32($1_DEF)') --- 74 unchanged lines hidden (view full) --- 140size_t 141_libelf_fsize(Elf_Type t, int ec, unsigned int v, size_t c) 142{ 143 size_t sz; 144 145 sz = 0; 146 if (v != EV_CURRENT) 147 LIBELF_SET_ERROR(VERSION, 0); |
146 else if ((int) t < ELF_T_FIRST || t > ELF_T_LAST) | 148 else if ((int) t < ELF_T_FIRST || t > ELF_T_LAST || 149 t == ELF_T_NOTE || t == ELF_T_GNUHASH) |
147 LIBELF_SET_ERROR(ARGUMENT, 0); 148 else { 149 sz = ec == ELFCLASS64 ? fsize[t].fsz64 : fsize[t].fsz32; 150 if (sz == 0) 151 LIBELF_SET_ERROR(UNIMPL, 0); 152 } 153 154 return (sz*c); 155} 156 | 150 LIBELF_SET_ERROR(ARGUMENT, 0); 151 else { 152 sz = ec == ELFCLASS64 ? fsize[t].fsz64 : fsize[t].fsz32; 153 if (sz == 0) 154 LIBELF_SET_ERROR(UNIMPL, 0); 155 } 156 157 return (sz*c); 158} 159 |