aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2008-12-26 18:37:24 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-26 18:37:24 -0500
commit627bf2f678ba7325461922af137ff5f20b6523eb (patch)
treec122deef6b73133c897c0104c5a0a1e776fb05ed /arch/sparc
parentc45d1c209f7420a01afd1f82c08af8d681fd56b8 (diff)
sparc64: prepare module_64.c for unification
o Introduce a helper function o Combine sparc64 specific case values o add ifdef's around sparc64 code snippets Note: The ifdef around the BUG_ON is highly questionable but for now the safe approach was taken Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/kernel/module_64.c62
1 files changed, 40 insertions, 22 deletions
diff --git a/arch/sparc/kernel/module_64.c b/arch/sparc/kernel/module_64.c
index 9f7e8d078d58..4deb88715039 100644
--- a/arch/sparc/kernel/module_64.c
+++ b/arch/sparc/kernel/module_64.c
@@ -16,6 +16,7 @@
16#include <asm/processor.h> 16#include <asm/processor.h>
17#include <asm/spitfire.h> 17#include <asm/spitfire.h>
18 18
19#ifdef CONFIG_SPARC64
19static void *module_map(unsigned long size) 20static void *module_map(unsigned long size)
20{ 21{
21 struct vm_struct *area; 22 struct vm_struct *area;
@@ -31,6 +32,12 @@ static void *module_map(unsigned long size)
31 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL); 32 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL);
32} 33}
33 34
35static char *dot2underscore(char *name)
36{
37 return name;
38}
39#endif /* CONFIG_SPARC64 */
40
34void *module_alloc(unsigned long size) 41void *module_alloc(unsigned long size)
35{ 42{
36 void *ret; 43 void *ret;
@@ -64,7 +71,7 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
64{ 71{
65 unsigned int symidx; 72 unsigned int symidx;
66 Elf_Sym *sym; 73 Elf_Sym *sym;
67 const char *strtab; 74 char *strtab;
68 int i; 75 int i;
69 76
70 for (symidx = 0; sechdrs[symidx].sh_type != SHT_SYMTAB; symidx++) { 77 for (symidx = 0; sechdrs[symidx].sh_type != SHT_SYMTAB; symidx++) {
@@ -77,9 +84,14 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
77 strtab = (char *)sechdrs[sechdrs[symidx].sh_link].sh_addr; 84 strtab = (char *)sechdrs[sechdrs[symidx].sh_link].sh_addr;
78 85
79 for (i = 1; i < sechdrs[symidx].sh_size / sizeof(Elf_Sym); i++) { 86 for (i = 1; i < sechdrs[symidx].sh_size / sizeof(Elf_Sym); i++) {
80 if (sym[i].st_shndx == SHN_UNDEF && 87 if (sym[i].st_shndx == SHN_UNDEF) {
81 ELF_ST_TYPE(sym[i].st_info) == STT_REGISTER) 88 if (ELF_ST_TYPE(sym[i].st_info) == STT_REGISTER) {
82 sym[i].st_shndx = SHN_ABS; 89 sym[i].st_shndx = SHN_ABS;
90 } else {
91 char *name = strtab + sym[i].st_name;
92 dot2underscore(name);
93 }
94 }
83 } 95 }
84 return 0; 96 return 0;
85} 97}
@@ -115,7 +127,9 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
115 + rel[i].r_offset; 127 + rel[i].r_offset;
116 loc32 = (u32 *) location; 128 loc32 = (u32 *) location;
117 129
130#ifdef CONFIG_SPARC64
118 BUG_ON(((u64)location >> (u64)32) != (u64)0); 131 BUG_ON(((u64)location >> (u64)32) != (u64)0);
132#endif /* CONFIG_SPARC64 */
119 133
120 /* This is the symbol it is referring to. Note that all 134 /* This is the symbol it is referring to. Note that all
121 undefined symbols have been resolved. */ 135 undefined symbols have been resolved. */
@@ -124,6 +138,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
124 v = sym->st_value + rel[i].r_addend; 138 v = sym->st_value + rel[i].r_addend;
125 139
126 switch (ELF_R_TYPE(rel[i].r_info) & 0xff) { 140 switch (ELF_R_TYPE(rel[i].r_info) & 0xff) {
141#ifdef CONFIG_SPARC64
127 case R_SPARC_64: 142 case R_SPARC_64:
128 location[0] = v >> 56; 143 location[0] = v >> 56;
129 location[1] = v >> 48; 144 location[1] = v >> 48;
@@ -135,6 +150,25 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
135 location[7] = v >> 0; 150 location[7] = v >> 0;
136 break; 151 break;
137 152
153 case R_SPARC_DISP32:
154 v -= (Elf_Addr) location;
155 *loc32 = v;
156 break;
157
158 case R_SPARC_WDISP19:
159 v -= (Elf_Addr) location;
160 *loc32 = (*loc32 & ~0x7ffff) |
161 ((v >> 2) & 0x7ffff);
162 break;
163
164 case R_SPARC_OLO10:
165 *loc32 = (*loc32 & ~0x1fff) |
166 (((v & 0x3ff) +
167 (ELF_R_TYPE(rel[i].r_info) >> 8))
168 & 0x1fff);
169 break;
170#endif /* CONFIG_SPARC64 */
171
138 case R_SPARC_32: 172 case R_SPARC_32:
139 location[0] = v >> 24; 173 location[0] = v >> 24;
140 location[1] = v >> 16; 174 location[1] = v >> 16;
@@ -142,11 +176,6 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
142 location[3] = v >> 0; 176 location[3] = v >> 0;
143 break; 177 break;
144 178
145 case R_SPARC_DISP32:
146 v -= (Elf_Addr) location;
147 *loc32 = v;
148 break;
149
150 case R_SPARC_WDISP30: 179 case R_SPARC_WDISP30:
151 v -= (Elf_Addr) location; 180 v -= (Elf_Addr) location;
152 *loc32 = (*loc32 & ~0x3fffffff) | 181 *loc32 = (*loc32 & ~0x3fffffff) |
@@ -159,12 +188,6 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
159 ((v >> 2) & 0x3fffff); 188 ((v >> 2) & 0x3fffff);
160 break; 189 break;
161 190
162 case R_SPARC_WDISP19:
163 v -= (Elf_Addr) location;
164 *loc32 = (*loc32 & ~0x7ffff) |
165 ((v >> 2) & 0x7ffff);
166 break;
167
168 case R_SPARC_LO10: 191 case R_SPARC_LO10:
169 *loc32 = (*loc32 & ~0x3ff) | (v & 0x3ff); 192 *loc32 = (*loc32 & ~0x3ff) | (v & 0x3ff);
170 break; 193 break;
@@ -174,13 +197,6 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
174 ((v >> 10) & 0x3fffff); 197 ((v >> 10) & 0x3fffff);
175 break; 198 break;
176 199
177 case R_SPARC_OLO10:
178 *loc32 = (*loc32 & ~0x1fff) |
179 (((v & 0x3ff) +
180 (ELF_R_TYPE(rel[i].r_info) >> 8))
181 & 0x1fff);
182 break;
183
184 default: 200 default:
185 printk(KERN_ERR "module %s: Unknown relocation: %x\n", 201 printk(KERN_ERR "module %s: Unknown relocation: %x\n",
186 me->name, 202 me->name,
@@ -191,6 +207,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
191 return 0; 207 return 0;
192} 208}
193 209
210#ifdef CONFIG_SPARC64
194int module_finalize(const Elf_Ehdr *hdr, 211int module_finalize(const Elf_Ehdr *hdr,
195 const Elf_Shdr *sechdrs, 212 const Elf_Shdr *sechdrs,
196 struct module *me) 213 struct module *me)
@@ -207,6 +224,7 @@ int module_finalize(const Elf_Ehdr *hdr,
207 224
208 return 0; 225 return 0;
209} 226}
227#endif /* CONFIG_SPARC64 */
210 228
211void module_arch_cleanup(struct module *mod) 229void module_arch_cleanup(struct module *mod)
212{ 230{