1 diff --git a/lib/elf_repl.h b/lib/elf_repl.h
2 index c5cf90f..7e1e8df 100644
5 @@ -45,7 +45,7 @@ typedef __libelf_u32_t Elf32_Word;
6 #define ELF32_FSZ_SWORD 4
7 #define ELF32_FSZ_WORD 4
10 +#if defined(__LIBELF64)
12 typedef __libelf_u64_t Elf64_Addr;
13 typedef __libelf_u16_t Elf64_Half;
14 @@ -93,7 +93,7 @@ typedef struct {
15 Elf32_Half e_shstrndx;
19 +#if defined(__LIBELF64)
21 unsigned char e_ident[EI_NIDENT];
23 @@ -307,7 +307,7 @@ typedef struct {
24 Elf32_Word sh_entsize;
28 +#if defined(__LIBELF64)
32 @@ -434,7 +434,7 @@ typedef struct {
37 +#if defined(__LIBELF64)
40 unsigned char st_info;
41 @@ -457,7 +457,7 @@ typedef struct {
42 #define ELF32_ST_TYPE(i) ((i)&0xf)
43 #define ELF32_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
46 +#if defined(__LIBELF64)
47 #define ELF64_ST_BIND(i) ((i)>>4)
48 #define ELF64_ST_TYPE(i) ((i)&0xf)
49 #define ELF64_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
50 @@ -495,7 +495,7 @@ typedef struct {
51 * Macros for manipulating st_other
53 #define ELF32_ST_VISIBILITY(o) ((o)&0x3)
55 +#if defined(__LIBELF64)
56 #define ELF64_ST_VISIBILITY(o) ((o)&0x3)
57 #endif /* __LIBELF64 */
59 @@ -521,7 +521,7 @@ typedef struct {
64 +#if defined(__LIBELF64)
68 @@ -541,7 +541,7 @@ typedef struct {
69 #define ELF32_R_TYPE(i) ((unsigned char)(i))
70 #define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t))
73 +#if defined(__LIBELF64)
74 #define ELF64_R_SYM(i) ((Elf64_Xword)(i)>>32)
75 #define ELF64_R_TYPE(i) ((i)&0xffffffffL)
76 #define ELF64_R_INFO(s,t) (((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))
77 @@ -556,7 +556,7 @@ typedef struct {
78 Elf32_Word n_type; /* descriptor type */
82 +#if defined(__LIBELF64)
83 /* Solaris and GNU use this layout. Be compatible. */
84 /* XXX: Latest ELF specs say it's 64-bit!!! */
86 @@ -587,7 +587,7 @@ typedef struct {
91 +#if defined(__LIBELF64)
95 @@ -654,7 +654,7 @@ typedef struct {
100 +#if defined(__LIBELF64)
104 @@ -798,7 +798,7 @@ typedef struct {
109 +#if defined(__LIBELF64)
111 Elf64_Half si_boundto;
113 @@ -863,7 +863,7 @@ typedef struct {
115 typedef Elf32_Half Elf32_Versym;
118 +#if defined(__LIBELF64)
121 Elf64_Half vd_version;
122 @@ -933,7 +933,7 @@ typedef Elf64_Half Elf64_Versym;
127 +#if defined(__LIBELF64)
131 @@ -973,7 +973,7 @@ typedef struct {
136 +#if defined(__LIBELF64)
140 diff --git a/lib/gelf.h b/lib/gelf.h
141 index 5af0558..98a759c 100644
148 -#if __LIBELF_INTERNAL__
149 +#if defined(__LIBELF_INTERNAL__)
151 #else /* __LIBELF_INTERNAL__ */
152 #include <libelf/libelf.h>
153 #endif /* __LIBELF_INTERNAL__ */
155 -#if __LIBELF_NEED_LINK_H
156 +#if defined(__LIBELF_NEED_LINK_H)
158 -#elif __LIBELF_NEED_SYS_LINK_H
159 +#elif defined(__LIBELF_NEED_SYS_LINK_H)
160 #include <sys/link.h>
161 #endif /* __LIBELF_NEED_LINK_H */
163 @@ -46,7 +46,7 @@ extern "C" {
164 # endif /* __STDC__ || defined(__cplusplus) */
168 +#if !defined(__LIBELF64)
170 #error "GElf is not supported on this system."
172 @@ -71,7 +71,7 @@ typedef Elf64_Sym GElf_Sym;
176 -#if __LIBELF_SYMBOL_VERSIONS
177 +#if defined(__LIBELF_SYMBOL_VERSIONS)
178 typedef Elf64_Verdef GElf_Verdef;
179 typedef Elf64_Verneed GElf_Verneed;
180 typedef Elf64_Verdaux GElf_Verdaux;
181 diff --git a/lib/libelf.h b/lib/libelf.h
182 index 3ebd0f3..788482d 100644
186 #include <stddef.h> /* for size_t */
187 #include <sys/types.h>
189 -#if __LIBELF_INTERNAL__
190 +#if defined(__LIBELF_INTERNAL__)
192 #else /* __LIBELF_INTERNAL__ */
193 #include <libelf/sys_elf.h>
194 @@ -224,7 +224,7 @@ extern Elf_Data *elf32_xlatetom __P((Elf_Data *__dst, const Elf_Data *__src,
196 extern long elf32_checksum __P((Elf *__elf));
199 +#if defined(__LIBELF64)
201 * 64-bit ELF functions
202 * Not available on all platforms
203 diff --git a/lib/sys_elf.h.in b/lib/sys_elf.h.in
204 index b71a20d..722051b 100644
205 --- a/lib/sys_elf.h.in
206 +++ b/lib/sys_elf.h.in
207 @@ -68,7 +68,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
208 #ifdef __LIBELF_HEADER_ELF_H
209 # include __LIBELF_HEADER_ELF_H
210 #else /* __LIBELF_HEADER_ELF_H */
211 -# if __LIBELF_INTERNAL__
212 +# if defined(__LIBELF_INTERNAL__)
213 # include <elf_repl.h>
214 # else /* __LIBELF_INTERNAL__ */
215 # include <libelf/elf_repl.h>
216 @@ -92,7 +92,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
218 # endif /* STN_UNDEF */
221 +# if defined(__LIBELF64)
223 # ifndef ELF64_FSZ_ADDR
224 # define ELF64_FSZ_ADDR 8
225 @@ -116,7 +116,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
226 # define ELF64_R_INFO(s,t) (((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))
227 # endif /* ELF64_R_SYM */
229 -# if __LIBELF64_LINUX
230 +# if defined(__LIBELF64_LINUX)
231 typedef __libelf_u64_t Elf64_Addr;
232 typedef __libelf_u16_t Elf64_Half;
233 typedef __libelf_u64_t Elf64_Off;
234 diff --git a/lib/sys_elf.h.w32 b/lib/sys_elf.h.w32
235 index 0f93c55..7360104 100644
236 --- a/lib/sys_elf.h.w32
237 +++ b/lib/sys_elf.h.w32
239 #ifdef __LIBELF_HEADER_ELF_H
240 # include __LIBELF_HEADER_ELF_H
241 #else /* __LIBELF_HEADER_ELF_H */
242 -# if __LIBELF_INTERNAL__
243 +# if defined(__LIBELF_INTERNAL__)
244 # include <elf_repl.h>
245 # else /* __LIBELF_INTERNAL__ */
246 # include <libelf/elf_repl.h>
249 # endif /* STN_UNDEF */
252 +# if defined(__LIBELF64)
254 # ifndef ELF64_FSZ_ADDR
255 # define ELF64_FSZ_ADDR 8
257 # define ELF64_R_INFO(s,t) (((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))
258 # endif /* ELF64_R_SYM */
260 -# if __LIBELF64_LINUX
261 +# if defined(__LIBELF64_LINUX)
262 typedef __libelf_u64_t Elf64_Addr;
263 typedef __libelf_u16_t Elf64_Half;
264 typedef __libelf_u64_t Elf64_Off;