fm/ipmitopo: fix 64-bit compilation
[unleashed.git] / include / libelf.h
blobd233391dde6eade9e3da5a28b7890e6dee968cd4
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
21 /* Copyright (c) 1988 AT&T */
22 /* All Rights Reserved */
25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 * Copyright 2014 PALO, Richard. All rights reserved.
30 #ifndef _LIBELF_H
31 #define _LIBELF_H
33 #include <sys/types.h>
34 #include <sys/elf.h>
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
41 typedef void Elf_Void;
44 * Commands
46 typedef enum {
47 ELF_C_NULL = 0, /* must be first, 0 */
48 ELF_C_READ,
49 ELF_C_WRITE,
50 ELF_C_CLR,
51 ELF_C_SET,
52 ELF_C_FDDONE,
53 ELF_C_FDREAD,
54 ELF_C_RDWR,
55 ELF_C_WRIMAGE,
56 ELF_C_IMAGE,
57 ELF_C_NUM /* must be last */
58 } Elf_Cmd;
62 * Flags
64 #define ELF_F_DIRTY 0x1
65 #define ELF_F_LAYOUT 0x4
69 * File types
71 typedef enum {
72 ELF_K_NONE = 0, /* must be first, 0 */
73 ELF_K_AR,
74 ELF_K_COFF,
75 ELF_K_ELF,
76 ELF_K_NUM /* must be last */
77 } Elf_Kind;
81 * Translation types
83 typedef enum {
84 ELF_T_BYTE = 0, /* must be first, 0 */
85 ELF_T_ADDR,
86 ELF_T_DYN,
87 ELF_T_EHDR,
88 ELF_T_HALF,
89 ELF_T_OFF,
90 ELF_T_PHDR,
91 ELF_T_RELA,
92 ELF_T_REL,
93 ELF_T_SHDR,
94 ELF_T_SWORD,
95 ELF_T_SYM,
96 ELF_T_WORD,
97 ELF_T_VDEF,
98 ELF_T_VNEED,
99 ELF_T_SXWORD,
100 ELF_T_XWORD,
101 ELF_T_SYMINFO,
102 ELF_T_NOTE,
103 ELF_T_MOVE,
104 ELF_T_MOVEP,
105 ELF_T_CAP,
106 ELF_T_NUM /* must be last */
107 } Elf_Type;
110 typedef struct Elf Elf;
111 typedef struct Elf_Scn Elf_Scn;
115 * Archive member header
117 typedef struct {
118 char *ar_name;
119 time_t ar_date;
120 uid_t ar_uid;
121 gid_t ar_gid;
122 mode_t ar_mode;
123 off_t ar_size;
124 char *ar_rawname;
125 } Elf_Arhdr;
129 * Archive symbol table
131 typedef struct {
132 char *as_name;
133 size_t as_off;
134 unsigned long as_hash;
135 } Elf_Arsym;
139 * Data descriptor
141 typedef struct {
142 Elf_Void *d_buf;
143 Elf_Type d_type;
144 size_t d_size;
145 off_t d_off; /* offset into section */
146 size_t d_align; /* alignment in section */
147 unsigned d_version; /* elf version */
148 } Elf_Data;
152 * Function declarations
154 Elf *elf_begin(int, Elf_Cmd, Elf *);
155 int elf_cntl(Elf *, Elf_Cmd);
156 int elf_end(Elf *);
157 const char *elf_errmsg(int);
158 int elf_errno(void);
159 void elf_fill(int);
160 unsigned elf_flagdata(Elf_Data *, Elf_Cmd, unsigned);
161 unsigned elf_flagehdr(Elf *, Elf_Cmd, unsigned);
162 unsigned elf_flagelf(Elf *, Elf_Cmd, unsigned);
163 unsigned elf_flagphdr(Elf *, Elf_Cmd, unsigned);
164 unsigned elf_flagscn(Elf_Scn *, Elf_Cmd, unsigned);
165 unsigned elf_flagshdr(Elf_Scn *, Elf_Cmd, unsigned);
166 size_t elf32_fsize(Elf_Type, size_t, unsigned);
167 Elf_Arhdr *elf_getarhdr(Elf *);
168 Elf_Arsym *elf_getarsym(Elf *, size_t *);
169 off_t elf_getbase(Elf *);
170 Elf_Data *elf_getdata(Elf_Scn *, Elf_Data *);
171 Elf32_Ehdr *elf32_getehdr(Elf *);
172 char *elf_getident(Elf *, size_t *);
173 Elf32_Phdr *elf32_getphdr(Elf *);
174 Elf_Scn *elf_getscn(Elf *elf, size_t);
175 Elf32_Shdr *elf32_getshdr(Elf_Scn *);
176 int elf_getphnum(Elf *, size_t *);
177 int elf_getphdrnum(Elf *, size_t *);
178 int elf_getshnum(Elf *, size_t *);
179 int elf_getshdrnum(Elf *, size_t *);
180 int elf_getshstrndx(Elf *, size_t *);
181 int elf_getshdrstrndx(Elf *, size_t *);
182 unsigned long elf_hash(const char *);
183 uint_t elf_sys_encoding(void);
184 long elf32_checksum(Elf *);
185 Elf_Kind elf_kind(Elf *);
186 Elf *elf_memory(char *, size_t);
187 size_t elf_ndxscn(Elf_Scn *);
188 Elf_Data *elf_newdata(Elf_Scn *);
189 Elf32_Ehdr *elf32_newehdr(Elf *);
190 Elf32_Phdr *elf32_newphdr(Elf *, size_t);
191 Elf_Scn *elf_newscn(Elf *);
192 Elf_Scn *elf_nextscn(Elf *, Elf_Scn *);
193 Elf_Cmd elf_next(Elf *);
194 size_t elf_rand(Elf *, size_t);
195 Elf_Data *elf_rawdata(Elf_Scn *, Elf_Data *);
196 char *elf_rawfile(Elf *, size_t *);
197 char *elf_strptr(Elf *, size_t, size_t);
198 off_t elf_update(Elf *, Elf_Cmd);
199 unsigned elf_version(unsigned);
200 Elf_Data *elf32_xlatetof(Elf_Data *, const Elf_Data *, unsigned);
201 Elf_Data *elf32_xlatetom(Elf_Data *, const Elf_Data *, unsigned);
203 size_t elf64_fsize(Elf_Type, size_t, unsigned);
204 Elf64_Ehdr *elf64_getehdr(Elf *);
205 Elf64_Phdr *elf64_getphdr(Elf *);
206 Elf64_Shdr *elf64_getshdr(Elf_Scn *);
207 long elf64_checksum(Elf *);
208 Elf64_Ehdr *elf64_newehdr(Elf *);
209 Elf64_Phdr *elf64_newphdr(Elf *, size_t);
210 Elf_Data *elf64_xlatetof(Elf_Data *, const Elf_Data *, unsigned);
211 Elf_Data *elf64_xlatetom(Elf_Data *, const Elf_Data *, unsigned);
213 #ifdef __cplusplus
215 #endif
217 #endif /* _LIBELF_H */