aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/module.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2011-01-06 20:29:26 -0500
committerPaul Mundt <lethal@linux-sh.org>2011-01-06 20:29:26 -0500
commit5e93c6b4ecd78b1bab49bad1dc2f6ed7ec0115ee (patch)
tree4f4e321a1ca0baf64d8af528080c71f93495a7d7 /arch/arm/kernel/module.c
parent98d27b8abf413a310df6676f7d2128ada1cccc08 (diff)
parent3c0cb7c31c206aaedb967e44b98442bbeb17a6c4 (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 into rmobile-latest
Conflicts: arch/arm/mach-shmobile/Kconfig Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/arm/kernel/module.c')
-rw-r--r--arch/arm/kernel/module.c109
1 files changed, 54 insertions, 55 deletions
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index d9bd786ce23..0c1bb68ff4a 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -67,35 +67,6 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
67 char *secstrings, 67 char *secstrings,
68 struct module *mod) 68 struct module *mod)
69{ 69{
70#ifdef CONFIG_ARM_UNWIND
71 Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum;
72 struct arm_unwind_mapping *maps = mod->arch.map;
73
74 for (s = sechdrs; s < sechdrs_end; s++) {
75 char const *secname = secstrings + s->sh_name;
76
77 if (strcmp(".ARM.exidx.init.text", secname) == 0)
78 maps[ARM_SEC_INIT].unw_sec = s;
79 else if (strcmp(".ARM.exidx.devinit.text", secname) == 0)
80 maps[ARM_SEC_DEVINIT].unw_sec = s;
81 else if (strcmp(".ARM.exidx", secname) == 0)
82 maps[ARM_SEC_CORE].unw_sec = s;
83 else if (strcmp(".ARM.exidx.exit.text", secname) == 0)
84 maps[ARM_SEC_EXIT].unw_sec = s;
85 else if (strcmp(".ARM.exidx.devexit.text", secname) == 0)
86 maps[ARM_SEC_DEVEXIT].unw_sec = s;
87 else if (strcmp(".init.text", secname) == 0)
88 maps[ARM_SEC_INIT].sec_text = s;
89 else if (strcmp(".devinit.text", secname) == 0)
90 maps[ARM_SEC_DEVINIT].sec_text = s;
91 else if (strcmp(".text", secname) == 0)
92 maps[ARM_SEC_CORE].sec_text = s;
93 else if (strcmp(".exit.text", secname) == 0)
94 maps[ARM_SEC_EXIT].sec_text = s;
95 else if (strcmp(".devexit.text", secname) == 0)
96 maps[ARM_SEC_DEVEXIT].sec_text = s;
97 }
98#endif
99 return 0; 70 return 0;
100} 71}
101 72
@@ -300,41 +271,69 @@ apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
300 return -ENOEXEC; 271 return -ENOEXEC;
301} 272}
302 273
303#ifdef CONFIG_ARM_UNWIND 274struct mod_unwind_map {
304static void register_unwind_tables(struct module *mod) 275 const Elf_Shdr *unw_sec;
276 const Elf_Shdr *txt_sec;
277};
278
279int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,
280 struct module *mod)
305{ 281{
282#ifdef CONFIG_ARM_UNWIND
283 const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
284 const Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum;
285 struct mod_unwind_map maps[ARM_SEC_MAX];
306 int i; 286 int i;
307 for (i = 0; i < ARM_SEC_MAX; ++i) { 287
308 struct arm_unwind_mapping *map = &mod->arch.map[i]; 288 memset(maps, 0, sizeof(maps));
309 if (map->unw_sec && map->sec_text) 289
310 map->unwind = unwind_table_add(map->unw_sec->sh_addr, 290 for (s = sechdrs; s < sechdrs_end; s++) {
311 map->unw_sec->sh_size, 291 const char *secname = secstrs + s->sh_name;
312 map->sec_text->sh_addr, 292
313 map->sec_text->sh_size); 293 if (!(s->sh_flags & SHF_ALLOC))
294 continue;
295
296 if (strcmp(".ARM.exidx.init.text", secname) == 0)
297 maps[ARM_SEC_INIT].unw_sec = s;
298 else if (strcmp(".ARM.exidx.devinit.text", secname) == 0)
299 maps[ARM_SEC_DEVINIT].unw_sec = s;
300 else if (strcmp(".ARM.exidx", secname) == 0)
301 maps[ARM_SEC_CORE].unw_sec = s;
302 else if (strcmp(".ARM.exidx.exit.text", secname) == 0)
303 maps[ARM_SEC_EXIT].unw_sec = s;
304 else if (strcmp(".ARM.exidx.devexit.text", secname) == 0)
305 maps[ARM_SEC_DEVEXIT].unw_sec = s;
306 else if (strcmp(".init.text", secname) == 0)
307 maps[ARM_SEC_INIT].txt_sec = s;
308 else if (strcmp(".devinit.text", secname) == 0)
309 maps[ARM_SEC_DEVINIT].txt_sec = s;
310 else if (strcmp(".text", secname) == 0)
311 maps[ARM_SEC_CORE].txt_sec = s;
312 else if (strcmp(".exit.text", secname) == 0)
313 maps[ARM_SEC_EXIT].txt_sec = s;
314 else if (strcmp(".devexit.text", secname) == 0)
315 maps[ARM_SEC_DEVEXIT].txt_sec = s;
314 } 316 }
315}
316 317
317static void unregister_unwind_tables(struct module *mod) 318 for (i = 0; i < ARM_SEC_MAX; i++)
318{ 319 if (maps[i].unw_sec && maps[i].txt_sec)
319 int i = ARM_SEC_MAX; 320 mod->arch.unwind[i] =
320 while (--i >= 0) 321 unwind_table_add(maps[i].unw_sec->sh_addr,
321 unwind_table_del(mod->arch.map[i].unwind); 322 maps[i].unw_sec->sh_size,
322} 323 maps[i].txt_sec->sh_addr,
323#else 324 maps[i].txt_sec->sh_size);
324static inline void register_unwind_tables(struct module *mod) { }
325static inline void unregister_unwind_tables(struct module *mod) { }
326#endif 325#endif
327
328int
329module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,
330 struct module *module)
331{
332 register_unwind_tables(module);
333 return 0; 326 return 0;
334} 327}
335 328
336void 329void
337module_arch_cleanup(struct module *mod) 330module_arch_cleanup(struct module *mod)
338{ 331{
339 unregister_unwind_tables(mod); 332#ifdef CONFIG_ARM_UNWIND
333 int i;
334
335 for (i = 0; i < ARM_SEC_MAX; i++)
336 if (mod->arch.unwind[i])
337 unwind_table_del(mod->arch.unwind[i]);
338#endif
340} 339}