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