1*6234Srie /* 2*6234Srie * CDDL HEADER START 3*6234Srie * 4*6234Srie * The contents of this file are subject to the terms of the 5*6234Srie * Common Development and Distribution License (the "License"). 6*6234Srie * You may not use this file except in compliance with the License. 7*6234Srie * 8*6234Srie * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*6234Srie * or http://www.opensolaris.org/os/licensing. 10*6234Srie * See the License for the specific language governing permissions 11*6234Srie * and limitations under the License. 12*6234Srie * 13*6234Srie * When distributing Covered Code, include this CDDL HEADER in each 14*6234Srie * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*6234Srie * If applicable, add the following below this CDDL HEADER, with the 16*6234Srie * fields enclosed by brackets "[]" replaced with your own identifying 17*6234Srie * information: Portions Copyright [yyyy] [name of copyright owner] 18*6234Srie * 19*6234Srie * CDDL HEADER END 20*6234Srie */ 21*6234Srie 22*6234Srie /* 23*6234Srie * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24*6234Srie * Use is subject to license terms. 25*6234Srie */ 26*6234Srie 27*6234Srie #ifndef __ELFWRAP_H 28*6234Srie #define __ELFWRAP_H 29*6234Srie 30*6234Srie #pragma ident "%Z%%M% %I% %E% SMI" 31*6234Srie 32*6234Srie /* 33*6234Srie * Local include file for elfwrap. 34*6234Srie */ 35*6234Srie #include <libelf.h> 36*6234Srie #include <alist.h> 37*6234Srie #include <_machelf.h> 38*6234Srie 39*6234Srie /* 40*6234Srie * Define a target descriptor to hold target specific information. 41*6234Srie */ 42*6234Srie typedef struct { 43*6234Srie uchar_t td_class; /* target class (32-bit/64-bit) */ 44*6234Srie uchar_t td_data; /* target data (LSB/MSB) */ 45*6234Srie ushort_t td_mach; /* target machine (sparc, i386, etc.) */ 46*6234Srie size_t td_align; /* target data buffer alignment */ 47*6234Srie size_t td_symsz; /* target symbol table entry size */ 48*6234Srie } TargDesc_t; 49*6234Srie 50*6234Srie /* 51*6234Srie * Define a descriptor for each ELF section being output to the new file. 52*6234Srie */ 53*6234Srie typedef struct { 54*6234Srie const char *os_name; /* section name */ 55*6234Srie Word os_type; /* section type */ 56*6234Srie Xword os_flags; /* section flags */ 57*6234Srie size_t os_ndx; /* section index (input file) */ 58*6234Srie off_t os_size; /* section size (input file) */ 59*6234Srie void *os_addr; /* section address (input file) */ 60*6234Srie Shdr *os_shdr; /* section header (output file) */ 61*6234Srie Elf_Data *os_data; /* section data (output file) */ 62*6234Srie } OutSec_t; 63*6234Srie 64*6234Srie #define AL_CNT_WOSECS 10 /* default number of input sections */ 65*6234Srie 66*6234Srie /* 67*6234Srie * Define a standard section descriptor. 68*6234Srie */ 69*6234Srie typedef struct { 70*6234Srie const char *ss_name; /* section name */ 71*6234Srie Word ss_type; /* section type */ 72*6234Srie Xword ss_flags; /* section flags */ 73*6234Srie } StdSec_t; 74*6234Srie 75*6234Srie /* 76*6234Srie * Define a descriptor to maintain section information. 77*6234Srie */ 78*6234Srie typedef struct { 79*6234Srie Alist *od_outsecs; /* list of output sections */ 80*6234Srie size_t od_symtabno; /* number of symbol table entries */ 81*6234Srie size_t od_strtabsz; /* string table size */ 82*6234Srie size_t od_shstrtabsz; /* section header string table size */ 83*6234Srie } ObjDesc_t; 84*6234Srie 85*6234Srie /* 86*6234Srie * Define all external interfaces. 87*6234Srie */ 88*6234Srie extern int input32(int, char **, const char *, const char *, ObjDesc_t *); 89*6234Srie extern int input64(int, char **, const char *, const char *, ObjDesc_t *); 90*6234Srie extern int output32(const char *, int, const char *, ushort_t, 91*6234Srie ObjDesc_t *); 92*6234Srie extern int output64(const char *, int, const char *, ushort_t, 93*6234Srie ObjDesc_t *); 94*6234Srie 95*6234Srie #if defined(lint) 96*6234Srie extern void target_init(TargDesc_t *); 97*6234Srie #else 98*6234Srie extern void target_init_sparc(TargDesc_t *); 99*6234Srie extern void target_init_sparcv9(TargDesc_t *); 100*6234Srie extern void target_init_i386(TargDesc_t *); 101*6234Srie extern void target_init_amd64(TargDesc_t *); 102*6234Srie #endif 103*6234Srie 104*6234Srie #ifdef __cplusplus 105*6234Srie extern "C" { 106*6234Srie #endif 107*6234Srie 108*6234Srie #ifdef __cplusplus 109*6234Srie } 110*6234Srie #endif 111*6234Srie 112*6234Srie #endif /* __ELFWRAP_H */ 113