Skip to contentSkip to conversation

ARM: module: fix unwind section relocation out of range error

PATCH Superseded William Zhang 2 participants 3 messages Sep 20, 2025 – Sep 22, 2025 Arm (32-bit)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: 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 within .text section and always meet range requirement.

---

 arch/arm/kernel/module-plts.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/kernel/module-plts.c +12 -0
index 354ce16d83cb..5f5bf5e63bd6 100644
@@ -225,6 +225,18 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
 			mod->arch.init.plt = s;
 		else if (s->sh_type == SHT_SYMTAB)
 			syms = (Elf32_Sym *)s->sh_addr;
+#if defined(CONFIG_ARM_UNWIND) && !defined(CONFIG_VMSPLIT_3G)
+		else if (s->sh_type == ELF_SECTION_UNWIND ||
+			 (strncmp(".ARM.extab", secstrings + s->sh_name, 10) == 0)) {
+			/*
+			 * To avoid the possible relocation out of range issue for
+			 * R_ARM_PREL31, mark unwind section .ARM.extab and .ARM.exidx as
+			 * executable so they will be allocated within .text section to meet
+			 * +/-1GB range requirement of the R_ARM_PREL31 relocation
+			 */
+			s->sh_flags |= SHF_EXECINSTR;
+		}
+#endif
 	}
 
 	if (!mod->arch.core.plt || !mod->arch.init.plt) {
Signature · 1 line
2.43.7
#1 lore raw

Hi William,

Quoted 6 lines · William Zhang

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)

Quoted 8 lines

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 within .text section and always meet range requirement.

Not "within" .text, but "along with" or "in close proximity to".

Quoted 4 lines

I think a Fixes tag might be appropriate?

Quoted 32 lines

---

 arch/arm/kernel/module-plts.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/kernel/module-plts.c +12 -1
index 354ce16d83cb..5f5bf5e63bd6 100644
@@ -225,6 +225,18 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
                        mod->arch.init.plt = s;
                else if (s->sh_type == SHT_SYMTAB)
                        syms = (Elf32_Sym *)s->sh_addr;
+#if defined(CONFIG_ARM_UNWIND) && !defined(CONFIG_VMSPLIT_3G)
+               else if (s->sh_type == ELF_SECTION_UNWIND ||
+                        (strncmp(".ARM.extab", secstrings + s->sh_name, 10) == 0)) {
+                       /*
+                        * To avoid the possible relocation out of range issue for
+                        * R_ARM_PREL31, mark unwind section .ARM.extab and .ARM.exidx as
+                        * executable so they will be allocated within .text section to meet
+                        * +/-1GB range requirement of the R_ARM_PREL31 relocation
+                        */
+                       s->sh_flags |= SHF_EXECINSTR;
+               }
+#endif
        }
 
        if (!mod->arch.core.plt || !mod->arch.init.plt) {
--

2.43.7

#2 lore raw

Hi Kursad,

Quoted 17 lines · Kursad Oney

Hi William,

Quoted 11 lines · William Zhang

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.

Quoted 5 lines
Quoted 3 lines

The fix is to mark .ARM.extab and .ARM.exidx sections as executable so they can be allocated within .text section and always meet range requirement.

Not "within" .text, but "along with" or "in close proximity to".

Yeah that is more accurate. Will update.

Quoted 7 lines
Quoted 5 lines

I think a Fixes tag might be appropriate?

Yes, the change ac3b43283923 ("module: replace module_layout with module_memory") does expose this issue. But I won't say that change itself has a bug and it is more of an enhancement that this arm module code has to handle different memory allocation scenarios.

Quoted 33 lines
Quoted 33 lines

---

 arch/arm/kernel/module-plts.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/kernel/module-plts.c +12 -1
index 354ce16d83cb..5f5bf5e63bd6 100644
@@ -225,6 +225,18 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
                        mod->arch.init.plt = s;
                else if (s->sh_type == SHT_SYMTAB)
                        syms = (Elf32_Sym *)s->sh_addr;
+#if defined(CONFIG_ARM_UNWIND) && !defined(CONFIG_VMSPLIT_3G)
+               else if (s->sh_type == ELF_SECTION_UNWIND ||
+                        (strncmp(".ARM.extab", secstrings + s->sh_name, 10) == 0)) {
+                       /*
+                        * To avoid the possible relocation out of range issue for
+                        * R_ARM_PREL31, mark unwind section .ARM.extab and .ARM.exidx as
+                        * executable so they will be allocated within .text section to meet
+                        * +/-1GB range requirement of the R_ARM_PREL31 relocation
+                        */
+                       s->sh_flags |= SHF_EXECINSTR;
+               }
+#endif
        }
 
        if (!mod->arch.core.plt || !mod->arch.init.plt) {
--

2.43.7