提交 e5f7772e 编写于 作者: P Phil Carmody 提交者: Russell King

ARM: 6339/1: module - simplify unwind table handling

The various sections are all dealt with similarly, so factor out
that common behaviour. (Incorporating Peter Huewe's fix.)

Cc: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: NPhil Carmody <ext-phil.2.carmody@nokia.com>
Acked-by: NCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
上级 57934326
...@@ -7,20 +7,25 @@ ...@@ -7,20 +7,25 @@
struct unwind_table; struct unwind_table;
struct mod_arch_specific
{
#ifdef CONFIG_ARM_UNWIND #ifdef CONFIG_ARM_UNWIND
Elf_Shdr *unw_sec_init; struct arm_unwind_mapping {
Elf_Shdr *unw_sec_devinit; Elf_Shdr *unw_sec;
Elf_Shdr *unw_sec_core; Elf_Shdr *sec_text;
Elf_Shdr *sec_init_text; struct unwind_table *unwind;
Elf_Shdr *sec_devinit_text; };
Elf_Shdr *sec_core_text; enum {
struct unwind_table *unwind_init; ARM_SEC_INIT,
struct unwind_table *unwind_devinit; ARM_SEC_DEVINIT,
struct unwind_table *unwind_core; ARM_SEC_CORE,
#endif ARM_SEC_MAX,
};
struct mod_arch_specific {
struct arm_unwind_mapping map[ARM_SEC_MAX];
}; };
#else
struct mod_arch_specific {
};
#endif
/* /*
* Include the ARM architecture version. * Include the ARM architecture version.
......
...@@ -69,22 +69,23 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, ...@@ -69,22 +69,23 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
{ {
#ifdef CONFIG_ARM_UNWIND #ifdef CONFIG_ARM_UNWIND
Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum; Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum;
struct arm_unwind_mapping *maps = mod->arch.map;
for (s = sechdrs; s < sechdrs_end; s++) { for (s = sechdrs; s < sechdrs_end; s++) {
char const *secname = secstrings + s->sh_name; char const *secname = secstrings + s->sh_name;
if (strcmp(".ARM.exidx.init.text", secname) == 0) if (strcmp(".ARM.exidx.init.text", secname) == 0)
mod->arch.unw_sec_init = s; maps[ARM_SEC_INIT].unw_sec = s;
else if (strcmp(".ARM.exidx.devinit.text", secname) == 0) else if (strcmp(".ARM.exidx.devinit.text", secname) == 0)
mod->arch.unw_sec_devinit = s; maps[ARM_SEC_DEVINIT].unw_sec = s;
else if (strcmp(".ARM.exidx", secname) == 0) else if (strcmp(".ARM.exidx", secname) == 0)
mod->arch.unw_sec_core = s; maps[ARM_SEC_CORE].unw_sec = s;
else if (strcmp(".init.text", secname) == 0) else if (strcmp(".init.text", secname) == 0)
mod->arch.sec_init_text = s; maps[ARM_SEC_INIT].sec_text = s;
else if (strcmp(".devinit.text", secname) == 0) else if (strcmp(".devinit.text", secname) == 0)
mod->arch.sec_devinit_text = s; maps[ARM_SEC_DEVINIT].sec_text = s;
else if (strcmp(".text", secname) == 0) else if (strcmp(".text", secname) == 0)
mod->arch.sec_core_text = s; maps[ARM_SEC_CORE].sec_text = s;
} }
#endif #endif
return 0; return 0;
...@@ -294,31 +295,22 @@ apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab, ...@@ -294,31 +295,22 @@ apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
#ifdef CONFIG_ARM_UNWIND #ifdef CONFIG_ARM_UNWIND
static void register_unwind_tables(struct module *mod) static void register_unwind_tables(struct module *mod)
{ {
if (mod->arch.unw_sec_init && mod->arch.sec_init_text) int i;
mod->arch.unwind_init = for (i = 0; i < ARM_SEC_MAX; ++i) {
unwind_table_add(mod->arch.unw_sec_init->sh_addr, struct arm_unwind_mapping *map = &mod->arch.map[i];
mod->arch.unw_sec_init->sh_size, if (map->unw_sec && map->sec_text)
mod->arch.sec_init_text->sh_addr, map->unwind = unwind_table_add(map->unw_sec->sh_addr,
mod->arch.sec_init_text->sh_size); map->unw_sec->sh_size,
if (mod->arch.unw_sec_devinit && mod->arch.sec_devinit_text) map->sec_text->sh_addr,
mod->arch.unwind_devinit = map->sec_text->sh_size);
unwind_table_add(mod->arch.unw_sec_devinit->sh_addr, }
mod->arch.unw_sec_devinit->sh_size,
mod->arch.sec_devinit_text->sh_addr,
mod->arch.sec_devinit_text->sh_size);
if (mod->arch.unw_sec_core && mod->arch.sec_core_text)
mod->arch.unwind_core =
unwind_table_add(mod->arch.unw_sec_core->sh_addr,
mod->arch.unw_sec_core->sh_size,
mod->arch.sec_core_text->sh_addr,
mod->arch.sec_core_text->sh_size);
} }
static void unregister_unwind_tables(struct module *mod) static void unregister_unwind_tables(struct module *mod)
{ {
unwind_table_del(mod->arch.unwind_init); int i = ARM_SEC_MAX;
unwind_table_del(mod->arch.unwind_devinit); while (--i >= 0)
unwind_table_del(mod->arch.unwind_core); unwind_table_del(mod->arch.map[i].unwind);
} }
#else #else
static inline void register_unwind_tables(struct module *mod) { } static inline void register_unwind_tables(struct module *mod) { }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册