mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] ARM: module: fix unwind section relocation out of range error
@ 2025-09-22 20:23 William Zhang
  2026-02-23  2:30 ` William Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: William Zhang @ 2025-09-22 20:23 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: song, linus.walleij, florian.fainelli, ardb, anand.gore,
	Broadcom Kernel List, kursad.oney, William Zhang,
	Sebastian Andrzej Siewior, Peter Zijlstra (Intel),
	Luis Chamberlain, linux-kernel, Thomas Gleixner,
	Christophe Leroy, Petr Pavlu, Russell King

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.

Fixes: ac3b43283923 ("module: replace module_layout with module_memory")

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>

---

Changes in v2:
- Fix the comment in code and commit message regarding the unwind
section location
- Add fix tag for more visibility

 arch/arm/kernel/module-plts.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/kernel/module-plts.c b/arch/arm/kernel/module-plts.c
index 354ce16d83cb..b5338fe59706 100644
--- a/arch/arm/kernel/module-plts.c
+++ b/arch/arm/kernel/module-plts.c
@@ -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 along with .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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ARM: module: fix unwind section relocation out of range error
  2025-09-22 20:23 [PATCH v2] ARM: module: fix unwind section relocation out of range error William Zhang
@ 2026-02-23  2:30 ` William Zhang
  2026-03-31 14:56   ` Ard Biesheuvel
  0 siblings, 1 reply; 4+ messages in thread
From: William Zhang @ 2026-02-23  2:30 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: song, linus.walleij, florian.fainelli, ardb, anand.gore,
	Broadcom Kernel List, kursad.oney, Sebastian Andrzej Siewior,
	Peter Zijlstra (Intel),
	Luis Chamberlain, linux-kernel, Thomas Gleixner,
	Christophe Leroy, Petr Pavlu, Russell King

[-- Attachment #1: Type: text/plain, Size: 2588 bytes --]

Hi,

On Mon, Sep 22, 2025 at 1:24 PM William Zhang
<william.zhang@broadcom.com> wrote:
>
> 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.
>
> Fixes: ac3b43283923 ("module: replace module_layout with module_memory")
>
> 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>
>
> ---
>
> Changes in v2:
> - Fix the comment in code and commit message regarding the unwind
> section location
> - Add fix tag for more visibility
>
>  arch/arm/kernel/module-plts.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/arch/arm/kernel/module-plts.c b/arch/arm/kernel/module-plts.c
> index 354ce16d83cb..b5338fe59706 100644
> --- a/arch/arm/kernel/module-plts.c
> +++ b/arch/arm/kernel/module-plts.c
> @@ -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 along with .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
>

Is this version okay to be accepted?

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5473 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ARM: module: fix unwind section relocation out of range error
  2026-02-23  2:30 ` William Zhang
@ 2026-03-31 14:56   ` Ard Biesheuvel
  2026-04-02  1:45     ` William Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2026-03-31 14:56 UTC (permalink / raw)
  To: William Zhang, linux-arm-kernel
  Cc: Song Liu, linus.walleij, florian.fainelli, anand.gore,
	Broadcom Kernel List, kursad.oney, Sebastian Andrzej Siewior,
	Peter Zijlstra, Luis Chamberlain, linux-kernel, Thomas Gleixner,
	Christophe Leroy, Petr Pavlu, Russell King

Hi,



On Mon, 23 Feb 2026, at 03:30, William Zhang wrote:
> Hi,
>
> On Mon, Sep 22, 2025 at 1:24 PM William Zhang
> <william.zhang@broadcom.com> wrote:
>>
>> 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.
>>
>> Fixes: ac3b43283923 ("module: replace module_layout with module_memory")
>>
>> 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>
>>
>> ---
>>
>> Changes in v2:
>> - Fix the comment in code and commit message regarding the unwind
>> section location
>> - Add fix tag for more visibility
>>
>>  arch/arm/kernel/module-plts.c | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/arch/arm/kernel/module-plts.c b/arch/arm/kernel/module-plts.c
>> index 354ce16d83cb..b5338fe59706 100644
>> --- a/arch/arm/kernel/module-plts.c
>> +++ b/arch/arm/kernel/module-plts.c
>> @@ -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 along with .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
>>
>
> Is this version okay to be accepted?
>

Please put it in Russell's patch tracker.

https://www.arm.linux.org.uk/developer/patches/


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ARM: module: fix unwind section relocation out of range error
  2026-03-31 14:56   ` Ard Biesheuvel
@ 2026-04-02  1:45     ` William Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: William Zhang @ 2026-04-02  1:45 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-arm-kernel, Song Liu, linus.walleij, florian.fainelli,
	anand.gore, Broadcom Kernel List, kursad.oney,
	Sebastian Andrzej Siewior, Peter Zijlstra, Luis Chamberlain,
	linux-kernel, Thomas Gleixner, Christophe Leroy, Petr Pavlu,
	Russell King

[-- Attachment #1: Type: text/plain, Size: 125 bytes --]

Hi,

>
> Please put it in Russell's patch tracker.
>
> https://www.arm.linux.org.uk/developer/patches/
>

Uploaded.  Thanks!

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5473 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-02  1:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-22 20:23 [PATCH v2] ARM: module: fix unwind section relocation out of range error William Zhang
2026-02-23  2:30 ` William Zhang
2026-03-31 14:56   ` Ard Biesheuvel
2026-04-02  1:45     ` William Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®