summaryrefslogtreecommitdiffstats
path: root/openembedded/packages/module-init-tools/files/depmod-byteswap.patch
diff options
context:
space:
mode:
Diffstat (limited to 'openembedded/packages/module-init-tools/files/depmod-byteswap.patch')
-rw-r--r--openembedded/packages/module-init-tools/files/depmod-byteswap.patch288
1 files changed, 0 insertions, 288 deletions
diff --git a/openembedded/packages/module-init-tools/files/depmod-byteswap.patch b/openembedded/packages/module-init-tools/files/depmod-byteswap.patch
deleted file mode 100644
index 1b46708b30..0000000000
--- a/openembedded/packages/module-init-tools/files/depmod-byteswap.patch
+++ /dev/null
@@ -1,288 +0,0 @@
1diff -u module-init-tools-3.1/orig/depmod.c module-init-tools-3.1/depmod.c
2--- module-init-tools-3.1/orig/depmod.c 2005-04-07 18:50:25.829635704 -0700
3+++ module-init-tools-3.1/depmod.c 2005-04-07 19:46:43.842099752 -0700
4@@ -17,6 +17,7 @@
5 #include <dirent.h>
6 #include <sys/utsname.h>
7 #include <sys/mman.h>
8+#include <endian.h>
9
10 #include "zlibsupport.h"
11 #include "depmod.h"
12@@ -303,16 +304,38 @@
13 goto fail;
14 }
15
16- switch (((char *)new->data)[EI_CLASS]) {
17- case ELFCLASS32:
18+ switch (((char *)new->data)[EI_CLASS] + (((char *)new->data)[EI_DATA] << 8)) {
19+ case ELFCLASS32 + (ELFDATA2LSB << 8): /* 32 bit little endian */
20+#if __BYTE_ORDER == __LITTLE_ENDIAN
21 new->ops = &mod_ops32;
22+#else
23+ new->ops = &mod_ops32swap;
24+#endif
25+ break;
26+ case ELFCLASS32 + (ELFDATA2MSB << 8): /* 32 bit big endian */
27+#if __BYTE_ORDER == __LITTLE_ENDIAN
28+ new->ops = &mod_ops32swap;
29+#else
30+ new->ops = &mod_ops32;
31+#endif
32 break;
33- case ELFCLASS64:
34+ case ELFCLASS64 + (ELFDATA2LSB << 8): /* 64 bit little endian */
35+#if __BYTE_ORDER == __LITTLE_ENDIAN
36 new->ops = &mod_ops64;
37+#else
38+ new->ops = &mod_ops64swap;
39+#endif
40+ break;
41+ case ELFCLASS64 + (ELFDATA2MSB << 8): /* 64 bit big endian */
42+#if __BYTE_ORDER == __LITTLE_ENDIAN
43+ new->ops = &mod_ops64swap;
44+#else
45+ new->ops = &mod_ops64;
46+#endif
47 break;
48 default:
49- warn("Module %s has elf unknown identifier %i\n",
50- new->pathname, ((char *)new->data)[EI_CLASS]);
51+ warn("Module %s has elf unknown identifier %i,%i\n",
52+ new->pathname, ((char *)new->data)[EI_CLASS], ((char *)new->data)[EI_DATA]);
53 goto fail;
54 }
55 return new;
56diff -u module-init-tools-3.1/orig/moduleops.c module-init-tools-3.1/moduleops.c
57--- module-init-tools-3.1/orig/moduleops.c 2005-04-07 18:50:25.829635704 -0700
58+++ module-init-tools-3.1/moduleops.c 2005-04-07 19:52:11.166338904 -0700
59@@ -9,15 +9,64 @@
60 #include "moduleops.h"
61 #include "tables.h"
62
63+/* This deals with both mis-aligned reads and endianness issues,
64+ * it may seem crude however the compiler knows 'size' at compile
65+ * time (because it comes from sizeof) therefore generates fairly
66+ * optimal code.
67+ */
68+static inline void read_native(const void *src, void *dest, unsigned int size)
69+{
70+ unsigned int i;
71+ for (i = 0; i < size; i++)
72+ ((unsigned char*)dest)[i] = ((unsigned char*)src)[i];
73+}
74+
75+#define NATIVE(x)\
76+({\
77+ typeof(x) __x;\
78+ read_native(&(x), &__x, sizeof __x);\
79+ __x;\
80+})
81+
82+static inline void read_swapped(const void *src, void *dest, unsigned int size)
83+{
84+ unsigned int i;
85+ for (i = 0; i < size; i++)
86+ ((unsigned char*)dest)[i] = ((unsigned char*)src)[size - i-1];
87+}
88+
89+#define SWAPPED(x)\
90+({\
91+ typeof(x) __x;\
92+ read_swapped(&(x), &__x, sizeof __x);\
93+ __x;\
94+})
95+
96+#define PERBITCOUNT(x) x##32
97 #define PERBIT(x) x##32
98 #define ElfPERBIT(x) Elf32_##x
99 #define ELFPERBIT(x) ELF32_##x
100+#define READ(x) NATIVE(x)
101+#include "moduleops_core.c"
102+#undef PERBIT
103+#undef READ
104+#define PERBIT(x) x##32swap
105+#define READ(x) SWAPPED(x)
106 #include "moduleops_core.c"
107
108+#undef PERBITCOUNT
109 #undef PERBIT
110 #undef ElfPERBIT
111 #undef ELFPERBIT
112+#undef READ
113+#define PERBITCOUNT(x) x##64
114 #define PERBIT(x) x##64
115 #define ElfPERBIT(x) Elf64_##x
116 #define ELFPERBIT(x) ELF64_##x
117+#define READ(x) NATIVE(x)
118+#include "moduleops_core.c"
119+#undef PERBIT
120+#undef READ
121+#define PERBIT(x) x##64swap
122+#define READ(x) SWAPPED(x)
123 #include "moduleops_core.c"
124diff -u module-init-tools-3.1/orig/moduleops.h module-init-tools-3.1/moduleops.h
125--- module-init-tools-3.1/orig/moduleops.h 2005-04-07 18:50:25.829635704 -0700
126+++ module-init-tools-3.1/moduleops.h 2005-04-07 19:36:26.184997904 -0700
127@@ -24,5 +24,6 @@
128 };
129
130 extern struct module_ops mod_ops32, mod_ops64;
131+extern struct module_ops mod_ops32swap, mod_ops64swap;
132
133 #endif /* MODINITTOOLS_MODULEOPS_H */
134diff -u module-init-tools-3.1/orig/moduleops_core.c module-init-tools-3.1/moduleops_core.c
135--- module-init-tools-3.1/orig/moduleops_core.c 2005-04-07 18:50:25.829635704 -0700
136+++ module-init-tools-3.1/moduleops_core.c 2005-04-07 19:56:18.794693672 -0700
137@@ -8,14 +8,14 @@
138 char *secnames;
139
140 /* Grab section headers and strings so we can tell who is who */
141- sechdrs = (void *)hdr + hdr->e_shoff;
142- secnames = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
143+ sechdrs = (void *)hdr + READ(hdr->e_shoff);
144+ secnames = (void *)hdr + READ(sechdrs[READ(hdr->e_shstrndx)].sh_offset);
145
146 /* Find the section they want */
147- for (i = 1; i < hdr->e_shnum; i++) {
148- if (strcmp(secnames+sechdrs[i].sh_name, secname) == 0) {
149- *size = sechdrs[i].sh_size;
150- return (void *)hdr + sechdrs[i].sh_offset;
151+ for (i = 1; i < READ(hdr->e_shnum); i++) {
152+ if (strcmp(secnames+READ(sechdrs[i].sh_name), secname) == 0) {
153+ *size = READ(sechdrs[i].sh_size);
154+ return (void *)hdr + READ(sechdrs[i].sh_offset);
155 }
156 }
157 *size = 0;
158@@ -24,7 +24,7 @@
159
160 static void PERBIT(load_symbols)(struct module *module)
161 {
162- struct PERBIT(kernel_symbol) *ksyms;
163+ struct PERBITCOUNT(kernel_symbol) *ksyms;
164 char *ksymstrings;
165 unsigned long i, size;
166
167@@ -58,10 +58,10 @@
168
169 /* Old-style. */
170 ksyms = PERBIT(load_section)(module->data, "__ksymtab", &size);
171- for (i = 0; i < size / sizeof(struct PERBIT(kernel_symbol)); i++)
172+ for (i = 0; i < size / sizeof(struct PERBITCOUNT(kernel_symbol)); i++)
173 add_symbol(ksyms[i].name, module);
174 ksyms = PERBIT(load_section)(module->data, "__gpl_ksymtab", &size);
175- for (i = 0; i < size / sizeof(struct PERBIT(kernel_symbol)); i++)
176+ for (i = 0; i < size / sizeof(struct PERBITCOUNT(kernel_symbol)); i++)
177 add_symbol(ksyms[i].name, module);
178 }
179
180@@ -100,16 +100,16 @@
181
182 hdr = module->data;
183 handle_register_symbols = 0;
184- if (hdr->e_machine == EM_SPARC ||
185- hdr->e_machine == EM_SPARCV9)
186+ if (READ(hdr->e_machine) == EM_SPARC ||
187+ READ(hdr->e_machine) == EM_SPARCV9)
188 handle_register_symbols = 1;
189
190 module->num_deps = 0;
191 module->deps = NULL;
192 for (i = 1; i < size / sizeof(syms[0]); i++) {
193- if (syms[i].st_shndx == SHN_UNDEF) {
194+ if (READ(syms[i].st_shndx) == SHN_UNDEF) {
195 /* Look for symbol */
196- const char *name = strings + syms[i].st_name;
197+ const char *name = strings + READ(syms[i].st_name);
198 struct module *owner;
199 int weak;
200
201@@ -118,11 +118,11 @@
202 variables, to avoid anyone else misusing
203 them. */
204 if (handle_register_symbols
205- && (ELFPERBIT(ST_TYPE)(syms[i].st_info)
206+ && (ELFPERBIT(ST_TYPE)(READ(syms[i].st_info))
207 == STT_REGISTER))
208 continue;
209
210- weak = ELFPERBIT(ST_BIND)(syms[i].st_info) == STB_WEAK;
211+ weak = ELFPERBIT(ST_BIND)(READ(syms[i].st_info)) == STB_WEAK;
212 owner = find_symbol(name, module->pathname, weak);
213 if (owner) {
214 if (verbose)
215@@ -143,7 +143,7 @@
216 ElfPERBIT(Sym) *syms;
217 ElfPERBIT(Shdr) *sechdrs;
218
219- sechdrs = (void *)hdr + hdr->e_shoff;
220+ sechdrs = (void *)hdr + READ(hdr->e_shoff);
221 strings = PERBIT(load_section)(hdr, ".strtab", &size);
222 syms = PERBIT(load_section)(hdr, ".symtab", &size);
223
224@@ -152,14 +152,14 @@
225 return NULL;
226
227 for (i = 0; i < size / sizeof(syms[0]); i++) {
228- if (strcmp(strings + syms[i].st_name, name) == 0) {
229+ if (strcmp(strings + READ(syms[i].st_name), name) == 0) {
230 /* In BSS? Happens for empty device tables on
231 * recent GCC versions. */
232- if (sechdrs[syms[i].st_shndx].sh_type == SHT_NOBITS)
233+ if (READ(sechdrs[READ(syms[i].st_shndx)].sh_type) == SHT_NOBITS)
234 return NULL;
235 return (void *)hdr
236- + sechdrs[syms[i].st_shndx].sh_offset
237- + syms[i].st_value;
238+ + READ(sechdrs[READ(syms[i].st_shndx)].sh_offset)
239+ + READ(syms[i].st_value);
240 }
241 }
242 return NULL;
243@@ -168,36 +168,36 @@
244 /* FIXME: Check size, unless we end up using aliases anyway --RR */
245 static void PERBIT(fetch_tables)(struct module *module)
246 {
247- module->pci_size = PERBIT(PCI_DEVICE_SIZE);
248+ module->pci_size = PERBITCOUNT(PCI_DEVICE_SIZE);
249 module->pci_table = PERBIT(deref_sym)(module->data,
250 "__mod_pci_device_table");
251
252- module->usb_size = PERBIT(USB_DEVICE_SIZE);
253+ module->usb_size = PERBITCOUNT(USB_DEVICE_SIZE);
254 module->usb_table = PERBIT(deref_sym)(module->data,
255 "__mod_usb_device_table");
256
257- module->ccw_size = PERBIT(CCW_DEVICE_SIZE);
258+ module->ccw_size = PERBITCOUNT(CCW_DEVICE_SIZE);
259 module->ccw_table = PERBIT(deref_sym)(module->data,
260 "__mod_ccw_device_table");
261
262- module->ieee1394_size = PERBIT(IEEE1394_DEVICE_SIZE);
263+ module->ieee1394_size = PERBITCOUNT(IEEE1394_DEVICE_SIZE);
264 module->ieee1394_table = PERBIT(deref_sym)(module->data,
265 "__mod_ieee1394_device_table");
266
267- module->pnp_size = PERBIT(PNP_DEVICE_SIZE);
268+ module->pnp_size = PERBITCOUNT(PNP_DEVICE_SIZE);
269 module->pnp_table = PERBIT(deref_sym)(module->data,
270 "__mod_pnp_device_table");
271
272- module->pnp_card_size = PERBIT(PNP_CARD_DEVICE_SIZE);
273+ module->pnp_card_size = PERBITCOUNT(PNP_CARD_DEVICE_SIZE);
274 module->pnp_card_table = PERBIT(deref_sym)(module->data,
275 "__mod_pnp_card_device_table");
276- module->pnp_card_offset = PERBIT(PNP_CARD_DEVICE_OFFSET);
277+ module->pnp_card_offset = PERBITCOUNT(PNP_CARD_DEVICE_OFFSET);
278
279- module->input_size = PERBIT(INPUT_DEVICE_SIZE);
280+ module->input_size = PERBITCOUNT(INPUT_DEVICE_SIZE);
281 module->input_table = PERBIT(deref_sym)(module->data,
282 "__mod_input_device_table");
283
284- module->soc_size = PERBIT(SOC_DEVICE_SIZE);
285+ module->soc_size = PERBITCOUNT(SOC_DEVICE_SIZE);
286 module->soc_table = PERBIT(deref_sym)(module->data,
287 "__mod_soc_device_table");
288