tools: libelf: fix headers to trigger -Wundef warnings
[openwrt/openwrt.git] / tools / libelf / patches / 900-fix-undefined-macro-access.patch
1 --- a/lib/elf_repl.h
2 +++ b/lib/elf_repl.h
3 @@ -45,7 +45,7 @@ typedef __libelf_u32_t Elf32_Word;
4 #define ELF32_FSZ_SWORD 4
5 #define ELF32_FSZ_WORD 4
6
7 -#if __LIBELF64
8 +#if defined(__LIBELF64)
9
10 typedef __libelf_u64_t Elf64_Addr;
11 typedef __libelf_u16_t Elf64_Half;
12 @@ -93,7 +93,7 @@ typedef struct {
13 Elf32_Half e_shstrndx;
14 } Elf32_Ehdr;
15
16 -#if __LIBELF64
17 +#if defined(__LIBELF64)
18 typedef struct {
19 unsigned char e_ident[EI_NIDENT];
20 Elf64_Half e_type;
21 @@ -307,7 +307,7 @@ typedef struct {
22 Elf32_Word sh_entsize;
23 } Elf32_Shdr;
24
25 -#if __LIBELF64
26 +#if defined(__LIBELF64)
27 typedef struct {
28 Elf64_Word sh_name;
29 Elf64_Word sh_type;
30 @@ -434,7 +434,7 @@ typedef struct {
31 Elf32_Half st_shndx;
32 } Elf32_Sym;
33
34 -#if __LIBELF64
35 +#if defined(__LIBELF64)
36 typedef struct {
37 Elf64_Word st_name;
38 unsigned char st_info;
39 @@ -457,7 +457,7 @@ typedef struct {
40 #define ELF32_ST_TYPE(i) ((i)&0xf)
41 #define ELF32_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
42
43 -#if __LIBELF64
44 +#if defined(__LIBELF64)
45 #define ELF64_ST_BIND(i) ((i)>>4)
46 #define ELF64_ST_TYPE(i) ((i)&0xf)
47 #define ELF64_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
48 @@ -495,7 +495,7 @@ typedef struct {
49 * Macros for manipulating st_other
50 */
51 #define ELF32_ST_VISIBILITY(o) ((o)&0x3)
52 -#if __LIBELF64
53 +#if defined(__LIBELF64)
54 #define ELF64_ST_VISIBILITY(o) ((o)&0x3)
55 #endif /* __LIBELF64 */
56
57 @@ -521,7 +521,7 @@ typedef struct {
58 Elf32_Sword r_addend;
59 } Elf32_Rela;
60
61 -#if __LIBELF64
62 +#if defined(__LIBELF64)
63 typedef struct {
64 Elf64_Addr r_offset;
65 Elf64_Xword r_info;
66 @@ -541,7 +541,7 @@ typedef struct {
67 #define ELF32_R_TYPE(i) ((unsigned char)(i))
68 #define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t))
69
70 -#if __LIBELF64
71 +#if defined(__LIBELF64)
72 #define ELF64_R_SYM(i) ((Elf64_Xword)(i)>>32)
73 #define ELF64_R_TYPE(i) ((i)&0xffffffffL)
74 #define ELF64_R_INFO(s,t) (((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))
75 @@ -556,7 +556,7 @@ typedef struct {
76 Elf32_Word n_type; /* descriptor type */
77 } Elf32_Nhdr;
78
79 -#if __LIBELF64
80 +#if defined(__LIBELF64)
81 /* Solaris and GNU use this layout. Be compatible. */
82 /* XXX: Latest ELF specs say it's 64-bit!!! */
83 typedef struct {
84 @@ -587,7 +587,7 @@ typedef struct {
85 Elf32_Word p_align;
86 } Elf32_Phdr;
87
88 -#if __LIBELF64
89 +#if defined(__LIBELF64)
90 typedef struct {
91 Elf64_Word p_type;
92 Elf64_Word p_flags;
93 @@ -654,7 +654,7 @@ typedef struct {
94 } d_un;
95 } Elf32_Dyn;
96
97 -#if __LIBELF64
98 +#if defined(__LIBELF64)
99 typedef struct {
100 Elf64_Sxword d_tag;
101 union {
102 @@ -798,7 +798,7 @@ typedef struct {
103 Elf32_Half si_flags;
104 } Elf32_Syminfo;
105
106 -#if __LIBELF64
107 +#if defined(__LIBELF64)
108 typedef struct {
109 Elf64_Half si_boundto;
110 Elf64_Half si_flags;
111 @@ -863,7 +863,7 @@ typedef struct {
112
113 typedef Elf32_Half Elf32_Versym;
114
115 -#if __LIBELF64
116 +#if defined(__LIBELF64)
117
118 typedef struct {
119 Elf64_Half vd_version;
120 @@ -933,7 +933,7 @@ typedef Elf64_Half Elf64_Versym;
121 /*
122 * Move section
123 */
124 -#if __LIBELF64
125 +#if defined(__LIBELF64)
126
127 typedef struct {
128 Elf32_Lword m_value;
129 @@ -973,7 +973,7 @@ typedef struct {
130 } c_un;
131 } Elf32_Cap;
132
133 -#if __LIBELF64
134 +#if defined(__LIBELF64)
135
136 typedef struct {
137 Elf64_Xword c_tag;
138 --- a/lib/gelf.h
139 +++ b/lib/gelf.h
140 @@ -22,15 +22,15 @@
141 #ifndef _GELF_H
142 #define _GELF_H
143
144 -#if __LIBELF_INTERNAL__
145 +#if defined(__LIBELF_INTERNAL__)
146 #include <libelf.h>
147 #else /* __LIBELF_INTERNAL__ */
148 #include <libelf/libelf.h>
149 #endif /* __LIBELF_INTERNAL__ */
150
151 -#if __LIBELF_NEED_LINK_H
152 +#if defined(__LIBELF_NEED_LINK_H)
153 #include <link.h>
154 -#elif __LIBELF_NEED_SYS_LINK_H
155 +#elif defined(__LIBELF_NEED_SYS_LINK_H)
156 #include <sys/link.h>
157 #endif /* __LIBELF_NEED_LINK_H */
158
159 @@ -71,7 +71,7 @@ typedef Elf64_Sym GElf_Sym;
160 /*
161 * Symbol versioning
162 */
163 -#if __LIBELF_SYMBOL_VERSIONS
164 +#if defined(__LIBELF_SYMBOL_VERSIONS)
165 typedef Elf64_Verdef GElf_Verdef;
166 typedef Elf64_Verneed GElf_Verneed;
167 typedef Elf64_Verdaux GElf_Verdaux;
168 --- a/lib/libelf.h
169 +++ b/lib/libelf.h
170 @@ -25,7 +25,7 @@
171 #include <stddef.h> /* for size_t */
172 #include <sys/types.h>
173
174 -#if __LIBELF_INTERNAL__
175 +#if defined(__LIBELF_INTERNAL__)
176 #include <sys_elf.h>
177 #else /* __LIBELF_INTERNAL__ */
178 #include <libelf/sys_elf.h>
179 @@ -224,7 +224,7 @@ extern Elf_Data *elf32_xlatetom __P((Elf
180 */
181 extern long elf32_checksum __P((Elf *__elf));
182
183 -#if __LIBELF64
184 +#if defined(__LIBELF64)
185 /*
186 * 64-bit ELF functions
187 * Not available on all platforms
188 --- a/lib/sys_elf.h.in
189 +++ b/lib/sys_elf.h.in
190 @@ -116,7 +116,7 @@ Foundation, Inc., 51 Franklin Street, Fi
191 # define ELF64_R_INFO(s,t) (((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))
192 # endif /* ELF64_R_SYM */
193
194 -# if __LIBELF64_LINUX
195 +# if defined(__LIBELF64_LINUX)
196 typedef __libelf_u64_t Elf64_Addr;
197 typedef __libelf_u16_t Elf64_Half;
198 typedef __libelf_u64_t Elf64_Off;