Skip to content

Commit

Permalink
ARM: 8976/1: module: allow arch overrides for .init section names
Browse files Browse the repository at this point in the history
ARM stores unwind information for .init.text in sections named
.ARM.extab.init.text and .ARM.exidx.init.text.  Since those aren't
currently recognized as init sections, they're allocated along with the
core section, and relocation fails if the core and the init section are
allocated from different regions and can't reach other.

  final section addresses:
        ...
        0x7f800000 .init.text
        ..
        0xcbb54078 .ARM.exidx.init.text
        ..

 section 16 reloc 0 sym '': relocation 42 out of range (0xcbb54078 ->
 0x7f800000)

Allow architectures to override the section name so that ARM can fix
this.

Acked-by: Jessica Yu <[email protected]>
Signed-off-by: Vincent Whitchurch <[email protected]>
Signed-off-by: Russell King <[email protected]>
  • Loading branch information
vwax authored and Russell King committed May 19, 2020
1 parent cdcb07e commit 2318976
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions include/linux/moduleloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ void *module_alloc(unsigned long size);
/* Free memory returned from module_alloc. */
void module_memfree(void *module_region);

/* Determines if the section name is an init section (that is only used during
* module loading).
*/
bool module_init_section(const char *name);

/* Determines if the section name is an exit section (that is only used during
* module unloading)
*/
Expand Down
9 changes: 7 additions & 2 deletions kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2400,7 +2400,7 @@ static void layout_sections(struct module *mod, struct load_info *info)
if ((s->sh_flags & masks[m][0]) != masks[m][0]
|| (s->sh_flags & masks[m][1])
|| s->sh_entsize != ~0UL
|| strstarts(sname, ".init"))
|| module_init_section(sname))
continue;
s->sh_entsize = get_offset(mod, &mod->core_layout.size, s, i);
pr_debug("\t%s\n", sname);
Expand Down Expand Up @@ -2433,7 +2433,7 @@ static void layout_sections(struct module *mod, struct load_info *info)
if ((s->sh_flags & masks[m][0]) != masks[m][0]
|| (s->sh_flags & masks[m][1])
|| s->sh_entsize != ~0UL
|| !strstarts(sname, ".init"))
|| !module_init_section(sname))
continue;
s->sh_entsize = (get_offset(mod, &mod->init_layout.size, s, i)
| INIT_OFFSET_MASK);
Expand Down Expand Up @@ -2768,6 +2768,11 @@ void * __weak module_alloc(unsigned long size)
return vmalloc_exec(size);
}

bool __weak module_init_section(const char *name)
{
return strstarts(name, ".init");
}

bool __weak module_exit_section(const char *name)
{
return strstarts(name, ".exit");
Expand Down

0 comments on commit 2318976

Please sign in to comment.