xref: /onnv-gate/usr/src/head/gelf.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_GELF_H
28*0Sstevel@tonic-gate #define	_GELF_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <sys/feature_tests.h>
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #include <libelf.h>
35*0Sstevel@tonic-gate #include <sys/link.h>
36*0Sstevel@tonic-gate 
37*0Sstevel@tonic-gate #ifdef	__cplusplus
38*0Sstevel@tonic-gate extern "C" {
39*0Sstevel@tonic-gate #endif
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate 
42*0Sstevel@tonic-gate #if !defined(_INT64_TYPE)
43*0Sstevel@tonic-gate #error "64-bit integer types are required by gelf."
44*0Sstevel@tonic-gate #endif
45*0Sstevel@tonic-gate 
46*0Sstevel@tonic-gate /*
47*0Sstevel@tonic-gate  * Class-independent ELF API for Elf utilities.  This is
48*0Sstevel@tonic-gate  * for manipulating Elf32 and Elf64 specific information
49*0Sstevel@tonic-gate  * in a format common to both classes.
50*0Sstevel@tonic-gate  */
51*0Sstevel@tonic-gate 
52*0Sstevel@tonic-gate typedef Elf64_Addr	GElf_Addr;
53*0Sstevel@tonic-gate typedef Elf64_Half	GElf_Half;
54*0Sstevel@tonic-gate typedef Elf64_Off	GElf_Off;
55*0Sstevel@tonic-gate typedef Elf64_Sword	GElf_Sword;
56*0Sstevel@tonic-gate typedef Elf64_Sxword	GElf_Sxword;
57*0Sstevel@tonic-gate typedef Elf64_Word	GElf_Word;
58*0Sstevel@tonic-gate typedef Elf64_Xword	GElf_Xword;
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate typedef Elf64_Ehdr	GElf_Ehdr;
61*0Sstevel@tonic-gate typedef	Elf64_Move	GElf_Move;
62*0Sstevel@tonic-gate typedef Elf64_Phdr	GElf_Phdr;
63*0Sstevel@tonic-gate typedef Elf64_Shdr	GElf_Shdr;
64*0Sstevel@tonic-gate typedef Elf64_Sym	GElf_Sym;
65*0Sstevel@tonic-gate typedef	Elf64_Syminfo	GElf_Syminfo;
66*0Sstevel@tonic-gate typedef Elf64_Rela	GElf_Rela;
67*0Sstevel@tonic-gate typedef Elf64_Rel	GElf_Rel;
68*0Sstevel@tonic-gate typedef Elf64_Dyn	GElf_Dyn;
69*0Sstevel@tonic-gate typedef Elf64_Cap	GElf_Cap;
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate /*
72*0Sstevel@tonic-gate  * The processing of versioning information can stay the
73*0Sstevel@tonic-gate  * same because both the Elf32 and Elf64 structures are
74*0Sstevel@tonic-gate  * of equal sizes.
75*0Sstevel@tonic-gate  */
76*0Sstevel@tonic-gate typedef Elf64_Verdef	GElf_Verdef;
77*0Sstevel@tonic-gate typedef Elf64_Verdaux	GElf_Verdaux;
78*0Sstevel@tonic-gate typedef Elf64_Verneed	GElf_Verneed;
79*0Sstevel@tonic-gate typedef Elf64_Vernaux	GElf_Vernaux;
80*0Sstevel@tonic-gate typedef Elf64_Versym	GElf_Versym;
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate /*
83*0Sstevel@tonic-gate  * move.m_info is encoded using the 64bit fields in Gelf.
84*0Sstevel@tonic-gate  */
85*0Sstevel@tonic-gate #define	GELF_M_SYM	ELF64_M_SYM
86*0Sstevel@tonic-gate #define	GELF_M_SIZE	ELF64_M_SIZE
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate /*
89*0Sstevel@tonic-gate  * sym.st_info field is same size for Elf32 and Elf64.
90*0Sstevel@tonic-gate  */
91*0Sstevel@tonic-gate #define	GELF_ST_BIND	ELF64_ST_BIND
92*0Sstevel@tonic-gate #define	GELF_ST_TYPE	ELF64_ST_TYPE
93*0Sstevel@tonic-gate #define	GELF_ST_INFO	ELF64_ST_INFO
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate 
96*0Sstevel@tonic-gate /*
97*0Sstevel@tonic-gate  * Elf64 r_info may have data field in type id's word,
98*0Sstevel@tonic-gate  * so GELF_R_TYPE is defined as ELF64_R_TYPE_ID in order
99*0Sstevel@tonic-gate  * to isolate the proper bits for the true type id.
100*0Sstevel@tonic-gate  */
101*0Sstevel@tonic-gate #define	GELF_R_TYPE		ELF64_R_TYPE_ID
102*0Sstevel@tonic-gate #define	GELF_R_SYM		ELF64_R_SYM
103*0Sstevel@tonic-gate #define	GELF_R_INFO		ELF64_R_INFO
104*0Sstevel@tonic-gate #define	GELF_R_TYPE_DATA	ELF64_R_TYPE_DATA
105*0Sstevel@tonic-gate #define	GELF_R_TYPE_ID		ELF64_R_TYPE_ID
106*0Sstevel@tonic-gate #define	GELF_R_TYPE_INFO	ELF64_R_TYPE_INFO
107*0Sstevel@tonic-gate 
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate 
110*0Sstevel@tonic-gate int		gelf_getclass(Elf*);
111*0Sstevel@tonic-gate size_t		gelf_fsize(Elf *, Elf_Type, size_t, uint_t);
112*0Sstevel@tonic-gate GElf_Ehdr *	gelf_getehdr(Elf *, GElf_Ehdr *);
113*0Sstevel@tonic-gate int		gelf_update_ehdr(Elf *, GElf_Ehdr *);
114*0Sstevel@tonic-gate unsigned long	gelf_newehdr(Elf *, int);
115*0Sstevel@tonic-gate GElf_Phdr *	gelf_getphdr(Elf *, int, GElf_Phdr *);
116*0Sstevel@tonic-gate int		gelf_update_phdr(Elf *, int, GElf_Phdr *);
117*0Sstevel@tonic-gate unsigned long	gelf_newphdr(Elf *, size_t);
118*0Sstevel@tonic-gate GElf_Shdr *	gelf_getshdr(Elf_Scn *,  GElf_Shdr *);
119*0Sstevel@tonic-gate int		gelf_update_shdr(Elf_Scn *, GElf_Shdr *);
120*0Sstevel@tonic-gate Elf_Data *	gelf_xlatetof(Elf *, Elf_Data *, const Elf_Data *, uint_t);
121*0Sstevel@tonic-gate Elf_Data *	gelf_xlatetom(Elf *, Elf_Data *, const Elf_Data *, uint_t);
122*0Sstevel@tonic-gate GElf_Sym *	gelf_getsym(Elf_Data *, int, GElf_Sym *);
123*0Sstevel@tonic-gate int		gelf_update_sym(Elf_Data *, int, GElf_Sym *);
124*0Sstevel@tonic-gate GElf_Sym *	gelf_getsymshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *,
125*0Sstevel@tonic-gate 		    Elf32_Word *);
126*0Sstevel@tonic-gate int		gelf_update_symshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *,
127*0Sstevel@tonic-gate 		    Elf32_Word);
128*0Sstevel@tonic-gate GElf_Syminfo *	gelf_getsyminfo(Elf_Data *, int, GElf_Syminfo *);
129*0Sstevel@tonic-gate int		gelf_update_syminfo(Elf_Data *, int, GElf_Syminfo *);
130*0Sstevel@tonic-gate GElf_Move *	gelf_getmove(Elf_Data *, int, GElf_Move *);
131*0Sstevel@tonic-gate int		gelf_update_move(Elf_Data *, int, GElf_Move *);
132*0Sstevel@tonic-gate GElf_Dyn *	gelf_getdyn(Elf_Data *, int, GElf_Dyn *);
133*0Sstevel@tonic-gate int		gelf_update_dyn(Elf_Data *, int, GElf_Dyn *);
134*0Sstevel@tonic-gate GElf_Rela *	gelf_getrela(Elf_Data *, int, GElf_Rela *);
135*0Sstevel@tonic-gate int		gelf_update_rela(Elf_Data *, int, GElf_Rela *);
136*0Sstevel@tonic-gate GElf_Rel *	gelf_getrel(Elf_Data *, int, GElf_Rel *);
137*0Sstevel@tonic-gate int		gelf_update_rel(Elf_Data *, int, GElf_Rel *);
138*0Sstevel@tonic-gate long		gelf_checksum(Elf *);
139*0Sstevel@tonic-gate GElf_Cap *	gelf_getcap(Elf_Data *, int, GElf_Cap *);
140*0Sstevel@tonic-gate int		gelf_update_cap(Elf_Data *, int, GElf_Cap *);
141*0Sstevel@tonic-gate 
142*0Sstevel@tonic-gate 
143*0Sstevel@tonic-gate #ifdef	__cplusplus
144*0Sstevel@tonic-gate }
145*0Sstevel@tonic-gate #endif
146*0Sstevel@tonic-gate 
147*0Sstevel@tonic-gate #endif	/* _GELF_H */
148