[OpenWrt-Devel] wireguard: unknown relocation: 102 [ARMv7 Thumb-2]

Jason A. Donenfeld Jason at zx2c4.com
Wed Jun 17 15:51:36 EDT 2020


Hi Rui,

On Wed, Jun 17, 2020 at 7:19 AM Rui Salvaterra <rsalvaterra at gmail.com> wrote:
> After a bit more digging [1], I believe I've narrowed it down.
> CONFIG_THUMB2_AVOID_R_ARM_THM_JUMP11=y is required in order to avoid
> the emission of R_ARM_THM_JUMP11 relocations in the WireGuard module.
> I'm now wondering why the compat modules haven't exhibited the same
> problem (maybe it was just a fluke), but since this kconfig option
> effectively implies -fno-optimize-sibling-calls [2], it's quite a
> hefty hammer. Is this something that can be solved in the WireGuard
> build itself?
>
> Thanks in advance,
> Rui
>
> [1] https://github.com/openwrt/openwrt/pull/3079#issuecomment-645297337
> [2] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/Makefile?h=linux-5.4.y#n125

Ahh hah, nice detective work. Reading the Kconfig description, it
looks like this is actually a toolchain bug with modules in general:

config THUMB2_AVOID_R_ARM_THM_JUMP11
       bool "Work around buggy Thumb-2 short branch relocations in gas"
       depends on THUMB2_KERNEL && MODULES
       default y
       help
         Various binutils versions can resolve Thumb-2 branches to
         locally-defined, preemptible global symbols as short-range "b.n"
         branch instructions.

         This is a problem, because there's no guarantee the final
         destination of the symbol, or any candidate locations for a
         trampoline, are within range of the branch.  For this reason, the
         kernel does not support fixing up the R_ARM_THM_JUMP11 (102)
         relocation in modules at all, and it makes little sense to add
         support.

         The symptom is that the kernel fails with an "unsupported
         relocation" error when loading some modules.

         Until fixed tools are available, passing
         -fno-optimize-sibling-calls to gcc should prevent gcc generating
         code which hits this problem, at the cost of a bit of extra runtime
         stack usage in some cases.

         The problem is described in more detail at:
             https://bugs.launchpad.net/binutils-linaro/+bug/725126

         Only Thumb-2 kernels are affected.

         Unless you are sure your tools don't have this problem, say Y.

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list