Print this page
4555 macro side-effects with /usr/include/libelf.h
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/libelf.h
+++ new/usr/src/head/libelf.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /* Copyright (c) 1988 AT&T */
22 22 /* All Rights Reserved */
23 23
24 24 /*
25 25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 26 * Use is subject to license terms.
27 + * Copyright 2014 PALO, Richard. All rights reserved.
27 28 */
28 29
29 30 #ifndef _LIBELF_H
30 31 #define _LIBELF_H
31 32
32 33 #include <sys/types.h>
33 34 #include <sys/elf.h>
34 35
35 36
36 37 #ifdef __cplusplus
37 38 extern "C" {
38 39 #endif
39 40
40 41
41 42 #if defined(_ILP32) && (_FILE_OFFSET_BITS != 32)
42 43 #error "large files are not supported by libelf"
43 44 #endif
44 45
46 +typedef void Elf_Void;
45 47
46 -#undef _
47 -#ifdef __STDC__
48 -typedef void Elf_Void;
49 -#define _(a) a
50 -#else
51 -typedef char Elf_Void;
52 -#define _(a) ()
53 -#undef const
54 -#define const
55 -#endif
56 -
57 -
58 48 /*
59 49 * Commands
60 50 */
61 51 typedef enum {
62 52 ELF_C_NULL = 0, /* must be first, 0 */
63 53 ELF_C_READ,
64 54 ELF_C_WRITE,
65 55 ELF_C_CLR,
66 56 ELF_C_SET,
67 57 ELF_C_FDDONE,
68 58 ELF_C_FDREAD,
69 59 ELF_C_RDWR,
70 60 ELF_C_WRIMAGE,
71 61 ELF_C_IMAGE,
72 62 ELF_C_NUM /* must be last */
73 63 } Elf_Cmd;
74 64
75 65
76 66 /*
77 67 * Flags
78 68 */
79 69 #define ELF_F_DIRTY 0x1
80 70 #define ELF_F_LAYOUT 0x4
81 71
82 72
83 73 /*
84 74 * File types
85 75 */
86 76 typedef enum {
87 77 ELF_K_NONE = 0, /* must be first, 0 */
88 78 ELF_K_AR,
89 79 ELF_K_COFF,
90 80 ELF_K_ELF,
91 81 ELF_K_NUM /* must be last */
92 82 } Elf_Kind;
93 83
94 84
95 85 /*
96 86 * Translation types
97 87 */
98 88 typedef enum {
99 89 ELF_T_BYTE = 0, /* must be first, 0 */
100 90 ELF_T_ADDR,
101 91 ELF_T_DYN,
102 92 ELF_T_EHDR,
103 93 ELF_T_HALF,
104 94 ELF_T_OFF,
105 95 ELF_T_PHDR,
106 96 ELF_T_RELA,
107 97 ELF_T_REL,
108 98 ELF_T_SHDR,
109 99 ELF_T_SWORD,
110 100 ELF_T_SYM,
111 101 ELF_T_WORD,
112 102 ELF_T_VDEF,
113 103 ELF_T_VNEED,
114 104 ELF_T_SXWORD,
115 105 ELF_T_XWORD,
116 106 ELF_T_SYMINFO,
117 107 ELF_T_NOTE,
118 108 ELF_T_MOVE,
119 109 ELF_T_MOVEP,
120 110 ELF_T_CAP,
121 111 ELF_T_NUM /* must be last */
122 112 } Elf_Type;
123 113
124 114
125 115 typedef struct Elf Elf;
126 116 typedef struct Elf_Scn Elf_Scn;
127 117
128 118
129 119 /*
130 120 * Archive member header
131 121 */
132 122 typedef struct {
133 123 char *ar_name;
134 124 time_t ar_date;
135 125 uid_t ar_uid;
136 126 gid_t ar_gid;
137 127 mode_t ar_mode;
138 128 off_t ar_size;
139 129 char *ar_rawname;
140 130 } Elf_Arhdr;
141 131
142 132
143 133 /*
144 134 * Archive symbol table
145 135 */
146 136 typedef struct {
147 137 char *as_name;
148 138 size_t as_off;
149 139 unsigned long as_hash;
150 140 } Elf_Arsym;
151 141
152 142
153 143 /*
154 144 * Data descriptor
155 145 */
156 146 typedef struct {
157 147 Elf_Void *d_buf;
158 148 Elf_Type d_type;
↓ open down ↓ |
91 lines elided |
↑ open up ↑ |
159 149 size_t d_size;
160 150 off_t d_off; /* offset into section */
161 151 size_t d_align; /* alignment in section */
162 152 unsigned d_version; /* elf version */
163 153 } Elf_Data;
164 154
165 155
166 156 /*
167 157 * Function declarations
168 158 */
169 -Elf *elf_begin _((int, Elf_Cmd, Elf *));
170 -int elf_cntl _((Elf *, Elf_Cmd));
171 -int elf_end _((Elf *));
172 -const char *elf_errmsg _((int));
173 -int elf_errno _((void));
174 -void elf_fill _((int));
175 -unsigned elf_flagdata _((Elf_Data *, Elf_Cmd, unsigned));
176 -unsigned elf_flagehdr _((Elf *, Elf_Cmd, unsigned));
177 -unsigned elf_flagelf _((Elf *, Elf_Cmd, unsigned));
178 -unsigned elf_flagphdr _((Elf *, Elf_Cmd, unsigned));
179 -unsigned elf_flagscn _((Elf_Scn *, Elf_Cmd, unsigned));
180 -unsigned elf_flagshdr _((Elf_Scn *, Elf_Cmd, unsigned));
181 -size_t elf32_fsize _((Elf_Type, size_t, unsigned));
182 -Elf_Arhdr *elf_getarhdr _((Elf *));
183 -Elf_Arsym *elf_getarsym _((Elf *, size_t *));
184 -off_t elf_getbase _((Elf *));
185 -Elf_Data *elf_getdata _((Elf_Scn *, Elf_Data *));
186 -Elf32_Ehdr *elf32_getehdr _((Elf *));
187 -char *elf_getident _((Elf *, size_t *));
188 -Elf32_Phdr *elf32_getphdr _((Elf *));
189 -Elf_Scn *elf_getscn _((Elf *elf, size_t));
190 -Elf32_Shdr *elf32_getshdr _((Elf_Scn *));
191 -int elf_getphnum _((Elf *, size_t *));
192 -int elf_getphdrnum _((Elf *, size_t *));
193 -int elf_getshnum _((Elf *, size_t *));
194 -int elf_getshdrnum _((Elf *, size_t *));
195 -int elf_getshstrndx _((Elf *, size_t *));
196 -int elf_getshdrstrndx _((Elf *, size_t *));
197 -unsigned long elf_hash _((const char *));
198 -uint_t elf_sys_encoding _((void));
199 -long elf32_checksum _((Elf *));
200 -Elf_Kind elf_kind _((Elf *));
201 -Elf *elf_memory _((char *, size_t));
202 -size_t elf_ndxscn _((Elf_Scn *));
203 -Elf_Data *elf_newdata _((Elf_Scn *));
204 -Elf32_Ehdr *elf32_newehdr _((Elf *));
205 -Elf32_Phdr *elf32_newphdr _((Elf *, size_t));
206 -Elf_Scn *elf_newscn _((Elf *));
207 -Elf_Scn *elf_nextscn _((Elf *, Elf_Scn *));
208 -Elf_Cmd elf_next _((Elf *));
209 -size_t elf_rand _((Elf *, size_t));
210 -Elf_Data *elf_rawdata _((Elf_Scn *, Elf_Data *));
211 -char *elf_rawfile _((Elf *, size_t *));
212 -char *elf_strptr _((Elf *, size_t, size_t));
213 -off_t elf_update _((Elf *, Elf_Cmd));
214 -unsigned elf_version _((unsigned));
215 -Elf_Data *elf32_xlatetof _((Elf_Data *, const Elf_Data *, unsigned));
216 -Elf_Data *elf32_xlatetom _((Elf_Data *, const Elf_Data *, unsigned));
159 +Elf *elf_begin(int, Elf_Cmd, Elf *);
160 +int elf_cntl(Elf *, Elf_Cmd);
161 +int elf_end(Elf *);
162 +const char *elf_errmsg(int);
163 +int elf_errno(void);
164 +void elf_fill(int);
165 +unsigned elf_flagdata(Elf_Data *, Elf_Cmd, unsigned);
166 +unsigned elf_flagehdr(Elf *, Elf_Cmd, unsigned);
167 +unsigned elf_flagelf(Elf *, Elf_Cmd, unsigned);
168 +unsigned elf_flagphdr(Elf *, Elf_Cmd, unsigned);
169 +unsigned elf_flagscn(Elf_Scn *, Elf_Cmd, unsigned);
170 +unsigned elf_flagshdr(Elf_Scn *, Elf_Cmd, unsigned);
171 +size_t elf32_fsize(Elf_Type, size_t, unsigned);
172 +Elf_Arhdr *elf_getarhdr(Elf *);
173 +Elf_Arsym *elf_getarsym(Elf *, size_t *);
174 +off_t elf_getbase(Elf *);
175 +Elf_Data *elf_getdata(Elf_Scn *, Elf_Data *);
176 +Elf32_Ehdr *elf32_getehdr(Elf *);
177 +char *elf_getident(Elf *, size_t *);
178 +Elf32_Phdr *elf32_getphdr(Elf *);
179 +Elf_Scn *elf_getscn(Elf *elf, size_t);
180 +Elf32_Shdr *elf32_getshdr(Elf_Scn *);
181 +int elf_getphnum(Elf *, size_t *);
182 +int elf_getphdrnum(Elf *, size_t *);
183 +int elf_getshnum(Elf *, size_t *);
184 +int elf_getshdrnum(Elf *, size_t *);
185 +int elf_getshstrndx(Elf *, size_t *);
186 +int elf_getshdrstrndx(Elf *, size_t *);
187 +unsigned long elf_hash(const char *);
188 +uint_t elf_sys_encoding(void);
189 +long elf32_checksum(Elf *);
190 +Elf_Kind elf_kind(Elf *);
191 +Elf *elf_memory(char *, size_t);
192 +size_t elf_ndxscn(Elf_Scn *);
193 +Elf_Data *elf_newdata(Elf_Scn *);
194 +Elf32_Ehdr *elf32_newehdr(Elf *);
195 +Elf32_Phdr *elf32_newphdr(Elf *, size_t);
196 +Elf_Scn *elf_newscn(Elf *);
197 +Elf_Scn *elf_nextscn(Elf *, Elf_Scn *);
198 +Elf_Cmd elf_next(Elf *);
199 +size_t elf_rand(Elf *, size_t);
200 +Elf_Data *elf_rawdata(Elf_Scn *, Elf_Data *);
201 +char *elf_rawfile(Elf *, size_t *);
202 +char *elf_strptr(Elf *, size_t, size_t);
203 +off_t elf_update(Elf *, Elf_Cmd);
204 +unsigned elf_version(unsigned);
205 +Elf_Data *elf32_xlatetof(Elf_Data *, const Elf_Data *, unsigned);
206 +Elf_Data *elf32_xlatetom(Elf_Data *, const Elf_Data *, unsigned);
217 207
218 208 #if defined(_LP64) || defined(_LONGLONG_TYPE)
219 -size_t elf64_fsize _((Elf_Type, size_t, unsigned));
220 -Elf64_Ehdr *elf64_getehdr _((Elf *));
221 -Elf64_Phdr *elf64_getphdr _((Elf *));
222 -Elf64_Shdr *elf64_getshdr _((Elf_Scn *));
223 -long elf64_checksum _((Elf *));
224 -Elf64_Ehdr *elf64_newehdr _((Elf *));
225 -Elf64_Phdr *elf64_newphdr _((Elf *, size_t));
226 -Elf_Data *elf64_xlatetof _((Elf_Data *, const Elf_Data *, unsigned));
227 -Elf_Data *elf64_xlatetom _((Elf_Data *, const Elf_Data *, unsigned));
209 +size_t elf64_fsize(Elf_Type, size_t, unsigned);
210 +Elf64_Ehdr *elf64_getehdr(Elf *);
211 +Elf64_Phdr *elf64_getphdr(Elf *);
212 +Elf64_Shdr *elf64_getshdr(Elf_Scn *);
213 +long elf64_checksum(Elf *);
214 +Elf64_Ehdr *elf64_newehdr(Elf *);
215 +Elf64_Phdr *elf64_newphdr(Elf *, size_t);
216 +Elf_Data *elf64_xlatetof(Elf_Data *, const Elf_Data *, unsigned);
217 +Elf_Data *elf64_xlatetom(Elf_Data *, const Elf_Data *, unsigned);
228 218 #endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */
229 219
230 -#undef _
231 -
232 220 #ifdef __cplusplus
233 221 }
234 222 #endif
235 223
236 224 #endif /* _LIBELF_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX