Magellan Linux

Contents of /trunk/kmod/patches/kmod-9-fix32bits.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1820 - (show annotations) (download)
Wed Jun 27 09:21:17 2012 UTC (11 years, 10 months ago) by niro
File size: 1982 byte(s)
-added patch to fix testsuite failures
1 diff --git a/testsuite/init_module.c b/testsuite/init_module.c
2 index 814998a..ed8b9fc 100644
3 --- a/testsuite/init_module.c
4 +++ b/testsuite/init_module.c
5 @@ -16,6 +16,7 @@
6 */
7
8 #include <assert.h>
9 +#include <elf.h>
10 #include <errno.h>
11 #include <dirent.h>
12 #include <fcntl.h>
13 @@ -206,6 +207,12 @@ static inline bool module_is_inkernel(const char *modname)
14 return ret;
15 }
16
17 +static uint8_t elf_identify(void *mem)
18 +{
19 + uint8_t *p = mem;
20 + return p[EI_CLASS];
21 +}
22 +
23 TS_EXPORT long init_module(void *mem, unsigned long len, const char *args);
24
25 /*
26 @@ -225,6 +232,8 @@ long init_module(void *mem, unsigned long len, const char *args)
27 const void *buf;
28 uint64_t bufsize;
29 int err;
30 + uint8_t class;
31 + off_t offset;
32
33 init_retcodes();
34
35 @@ -237,13 +246,20 @@ long init_module(void *mem, unsigned long len, const char *args)
36 kmod_elf_unref(elf);
37
38 /*
39 - * We couldn't find the module's name inside the ELF file. Just exit
40 - * as if it was successful
41 + * We couldn't find the parse the ELF file. Just exit as if it was
42 + * successful
43 */
44 if (err < 0)
45 return 0;
46
47 - modname = (char *)buf + offsetof(struct module, name);
48 + /* We need to open both 32 and 64 bits module - hack! */
49 + class = elf_identify(mem);
50 + if (class == ELFCLASS64)
51 + offset = MODULE_NAME_OFFSET_64;
52 + else
53 + offset = MODULE_NAME_OFFSET_32;
54 +
55 + modname = (char *)buf + offset;
56 mod = find_module(modules, modname);
57 if (mod != NULL) {
58 errno = mod->errcode;
59 diff --git a/testsuite/stripped-module.h b/testsuite/stripped-module.h
60 index 9f97dae..19862f3 100644
61 --- a/testsuite/stripped-module.h
62 +++ b/testsuite/stripped-module.h
63 @@ -13,6 +13,7 @@ struct list_head {
64 };
65
66 #define MODULE_NAME_LEN (64 - sizeof(unsigned long))
67 +
68 struct module
69 {
70 enum module_state state;
71 @@ -24,4 +25,8 @@ struct module
72 char name[MODULE_NAME_LEN];
73 };
74
75 +/* padding */
76 +#define MODULE_NAME_OFFSET_64 4 + 4 + 2 * 8
77 +#define MODULE_NAME_OFFSET_32 4 + 2 * 4
78 +
79 #endif