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: Phil Carmody <ext-phil.2.carmody@nokia.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
Phil Carmody 2010-08-19 15:16:37 +01:00 committed by Russell King
parent 5793432628
commit e5f7772eec
2 changed files with 36 additions and 39 deletions

View File

@ -7,20 +7,25 @@
struct unwind_table;
struct mod_arch_specific
{
#ifdef CONFIG_ARM_UNWIND
Elf_Shdr *unw_sec_init;
Elf_Shdr *unw_sec_devinit;
Elf_Shdr *unw_sec_core;
Elf_Shdr *sec_init_text;
Elf_Shdr *sec_devinit_text;
Elf_Shdr *sec_core_text;
struct unwind_table *unwind_init;
struct unwind_table *unwind_devinit;
struct unwind_table *unwind_core;
#endif
struct arm_unwind_mapping {
Elf_Shdr *unw_sec;
Elf_Shdr *sec_text;
struct unwind_table *unwind;
};
enum {
ARM_SEC_INIT,
ARM_SEC_DEVINIT,
ARM_SEC_CORE,
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.

View File

@ -69,22 +69,23 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
{
#ifdef CONFIG_ARM_UNWIND
Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum;
struct arm_unwind_mapping *maps = mod->arch.map;
for (s = sechdrs; s < sechdrs_end; s++) {
char const *secname = secstrings + s->sh_name;
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)
mod->arch.unw_sec_devinit = s;
maps[ARM_SEC_DEVINIT].unw_sec = s;
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)
mod->arch.sec_init_text = s;
maps[ARM_SEC_INIT].sec_text = s;
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)
mod->arch.sec_core_text = s;
maps[ARM_SEC_CORE].sec_text = s;
}
#endif
return 0;
@ -294,31 +295,22 @@ apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
#ifdef CONFIG_ARM_UNWIND
static void register_unwind_tables(struct module *mod)
{
if (mod->arch.unw_sec_init && mod->arch.sec_init_text)
mod->arch.unwind_init =
unwind_table_add(mod->arch.unw_sec_init->sh_addr,
mod->arch.unw_sec_init->sh_size,
mod->arch.sec_init_text->sh_addr,
mod->arch.sec_init_text->sh_size);
if (mod->arch.unw_sec_devinit && mod->arch.sec_devinit_text)
mod->arch.unwind_devinit =
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);
int i;
for (i = 0; i < ARM_SEC_MAX; ++i) {
struct arm_unwind_mapping *map = &mod->arch.map[i];
if (map->unw_sec && map->sec_text)
map->unwind = unwind_table_add(map->unw_sec->sh_addr,
map->unw_sec->sh_size,
map->sec_text->sh_addr,
map->sec_text->sh_size);
}
}
static void unregister_unwind_tables(struct module *mod)
{
unwind_table_del(mod->arch.unwind_init);
unwind_table_del(mod->arch.unwind_devinit);
unwind_table_del(mod->arch.unwind_core);
int i = ARM_SEC_MAX;
while (--i >= 0)
unwind_table_del(mod->arch.map[i].unwind);
}
#else
static inline void register_unwind_tables(struct module *mod) { }