Skip to content

Commit 5a21253

Browse files
William ZhangRussell King (Oracle)
authored andcommitted
ARM: 9471/1: module: fix unwind section relocation out of range error
In an armv7 system that uses non-3G/1G split and with more than 512MB physical memory, driver load may fail with following error: section 29 reloc 0 sym '': relocation 42 out of range (0xc2ab9be8 -> 0x7fad5998) This happens when relocation R_ARM_PREL31 from the unwind section .ARM.extab and .ARM.exidx are allocated from the VMALLOC space while .text section is from MODULES_VADDR space. It exceeds the +/-1GB relocation requirement of R_ARM_PREL31 hence triggers the error. The fix is to mark .ARM.extab and .ARM.exidx sections as executable so they can be allocated along with .text section and always meet range requirement. Co-developed-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: William Zhang <william.zhang@broadcom.com> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
1 parent 6de23f8 commit 5a21253

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

arch/arm/kernel/module-plts.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,18 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
225225
mod->arch.init.plt = s;
226226
else if (s->sh_type == SHT_SYMTAB)
227227
syms = (Elf32_Sym *)s->sh_addr;
228+
#if defined(CONFIG_ARM_UNWIND) && !defined(CONFIG_VMSPLIT_3G)
229+
else if (s->sh_type == ELF_SECTION_UNWIND ||
230+
(strncmp(".ARM.extab", secstrings + s->sh_name, 10) == 0)) {
231+
/*
232+
* To avoid the possible relocation out of range issue for
233+
* R_ARM_PREL31, mark unwind section .ARM.extab and .ARM.exidx as
234+
* executable so they will be allocated along with .text section to
235+
* meet +/-1GB range requirement of the R_ARM_PREL31 relocation
236+
*/
237+
s->sh_flags |= SHF_EXECINSTR;
238+
}
239+
#endif
228240
}
229241

230242
if (!mod->arch.core.plt || !mod->arch.init.plt) {

0 commit comments

Comments
 (0)