diff options
author | Greg Ungerer <gerg@uclinux.org> | 2011-03-21 23:39:27 -0400 |
---|---|---|
committer | Greg Ungerer <gerg@uclinux.org> | 2011-03-25 00:05:13 -0400 |
commit | 66d857b08b8c3ed5c72c361f863cce77d2a978d7 (patch) | |
tree | 47222d86f4d78dc0da31baf64188bd2e4b38ac1e /arch/m68k/kernel/module_no.c | |
parent | d39dd11c3e6a7af5c20bfac40594db36cf270f42 (diff) |
m68k: merge m68k and m68knommu arch directories
There is a lot of common code that could be shared between the m68k
and m68knommu arch branches. It makes sense to merge the two branches
into a single directory structure so that we can more easily share
that common code.
This is a brute force merge, based on a script from Stephen King
<sfking@fdwdc.com>, which was originally written by Arnd Bergmann
<arnd@arndb.de>.
> The script was inspired by the script Sam Ravnborg used to merge the
> includes from m68knommu. For those files common to both arches but
> differing in content, the m68k version of the file is renamed to
> <file>_mm.<ext> and the m68knommu version of the file is moved into the
> corresponding m68k directory and renamed <file>_no.<ext> and a small
> wrapper file <file>.<ext> is used to select between the two version. Files
> that are common to both but don't differ are removed from the m68knommu
> tree and files and directories that are unique to the m68knommu tree are
> moved to the m68k tree. Finally, the arch/m68knommu tree is removed.
>
> To select between the the versions of the files, the wrapper uses
>
> #ifdef CONFIG_MMU
> #include <file>_mm.<ext>
> #else
> #include <file>_no.<ext>
> #endif
On top of this file merge I have done a simplistic merge of m68k and
m68knommu Kconfig, which primarily attempts to keep existing options and
menus in place. Other than a handful of options being moved it produces
identical .config outputs on m68k and m68knommu targets I tested it on.
With this in place there is now quite a bit of scope for merge cleanups
in future patches.
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
Diffstat (limited to 'arch/m68k/kernel/module_no.c')
-rw-r--r-- | arch/m68k/kernel/module_no.c | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/arch/m68k/kernel/module_no.c b/arch/m68k/kernel/module_no.c new file mode 100644 index 000000000000..d11ffae7956a --- /dev/null +++ b/arch/m68k/kernel/module_no.c | |||
@@ -0,0 +1,126 @@ | |||
1 | #include <linux/moduleloader.h> | ||
2 | #include <linux/elf.h> | ||
3 | #include <linux/vmalloc.h> | ||
4 | #include <linux/fs.h> | ||
5 | #include <linux/string.h> | ||
6 | #include <linux/kernel.h> | ||
7 | |||
8 | #if 0 | ||
9 | #define DEBUGP printk | ||
10 | #else | ||
11 | #define DEBUGP(fmt...) | ||
12 | #endif | ||
13 | |||
14 | void *module_alloc(unsigned long size) | ||
15 | { | ||
16 | if (size == 0) | ||
17 | return NULL; | ||
18 | return vmalloc(size); | ||
19 | } | ||
20 | |||
21 | |||
22 | /* Free memory returned from module_alloc */ | ||
23 | void module_free(struct module *mod, void *module_region) | ||
24 | { | ||
25 | vfree(module_region); | ||
26 | } | ||
27 | |||
28 | /* We don't need anything special. */ | ||
29 | int module_frob_arch_sections(Elf_Ehdr *hdr, | ||
30 | Elf_Shdr *sechdrs, | ||
31 | char *secstrings, | ||
32 | struct module *mod) | ||
33 | { | ||
34 | return 0; | ||
35 | } | ||
36 | |||
37 | int apply_relocate(Elf32_Shdr *sechdrs, | ||
38 | const char *strtab, | ||
39 | unsigned int symindex, | ||
40 | unsigned int relsec, | ||
41 | struct module *me) | ||
42 | { | ||
43 | unsigned int i; | ||
44 | Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr; | ||
45 | Elf32_Sym *sym; | ||
46 | uint32_t *location; | ||
47 | |||
48 | DEBUGP("Applying relocate section %u to %u\n", relsec, | ||
49 | sechdrs[relsec].sh_info); | ||
50 | for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { | ||
51 | /* This is where to make the change */ | ||
52 | location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr | ||
53 | + rel[i].r_offset; | ||
54 | /* This is the symbol it is referring to. Note that all | ||
55 | undefined symbols have been resolved. */ | ||
56 | sym = (Elf32_Sym *)sechdrs[symindex].sh_addr | ||
57 | + ELF32_R_SYM(rel[i].r_info); | ||
58 | |||
59 | switch (ELF32_R_TYPE(rel[i].r_info)) { | ||
60 | case R_68K_32: | ||
61 | /* We add the value into the location given */ | ||
62 | *location += sym->st_value; | ||
63 | break; | ||
64 | case R_68K_PC32: | ||
65 | /* Add the value, subtract its postition */ | ||
66 | *location += sym->st_value - (uint32_t)location; | ||
67 | break; | ||
68 | default: | ||
69 | printk(KERN_ERR "module %s: Unknown relocation: %u\n", | ||
70 | me->name, ELF32_R_TYPE(rel[i].r_info)); | ||
71 | return -ENOEXEC; | ||
72 | } | ||
73 | } | ||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | int apply_relocate_add(Elf32_Shdr *sechdrs, | ||
78 | const char *strtab, | ||
79 | unsigned int symindex, | ||
80 | unsigned int relsec, | ||
81 | struct module *me) | ||
82 | { | ||
83 | unsigned int i; | ||
84 | Elf32_Rela *rel = (void *)sechdrs[relsec].sh_addr; | ||
85 | Elf32_Sym *sym; | ||
86 | uint32_t *location; | ||
87 | |||
88 | DEBUGP("Applying relocate_add section %u to %u\n", relsec, | ||
89 | sechdrs[relsec].sh_info); | ||
90 | for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { | ||
91 | /* This is where to make the change */ | ||
92 | location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr | ||
93 | + rel[i].r_offset; | ||
94 | /* This is the symbol it is referring to. Note that all | ||
95 | undefined symbols have been resolved. */ | ||
96 | sym = (Elf32_Sym *)sechdrs[symindex].sh_addr | ||
97 | + ELF32_R_SYM(rel[i].r_info); | ||
98 | |||
99 | switch (ELF32_R_TYPE(rel[i].r_info)) { | ||
100 | case R_68K_32: | ||
101 | /* We add the value into the location given */ | ||
102 | *location = rel[i].r_addend + sym->st_value; | ||
103 | break; | ||
104 | case R_68K_PC32: | ||
105 | /* Add the value, subtract its postition */ | ||
106 | *location = rel[i].r_addend + sym->st_value - (uint32_t)location; | ||
107 | break; | ||
108 | default: | ||
109 | printk(KERN_ERR "module %s: Unknown relocation: %u\n", | ||
110 | me->name, ELF32_R_TYPE(rel[i].r_info)); | ||
111 | return -ENOEXEC; | ||
112 | } | ||
113 | } | ||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | int module_finalize(const Elf_Ehdr *hdr, | ||
118 | const Elf_Shdr *sechdrs, | ||
119 | struct module *me) | ||
120 | { | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | void module_arch_cleanup(struct module *mod) | ||
125 | { | ||
126 | } | ||