Skip to contentSkip to conversation

arm: vdso: pass --be8 to linker if necessary

PATCH In review Jason A. Donenfeld 3 participants 6 messages May 29, 2019 – Jun 18, 2019 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: vdso: pass --be8 to linker if necessary

The commit fe00e50b2db8 ("ARM: 8858/1: vdso: use $(LD) instead of $(CC) to link VDSO") removed the passing of CFLAGS, since ld doesn't take those directly. However, prior, big-endian ARM was relying on gcc to translate its -mbe8 option into ld's --be8 option. Lacking this, ld generated be32 code, making the VDSO generate SIGILL when called by userspace.

This commit passes --be8 if CONFIG_CPU_ENDIAN_BE8 is enabled.

Cc Masahiro Yamada <[email protected]>
Cc Russell King <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Ard Biesheuvel <[email protected]>
---
 arch/arm/vdso/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/vdso/Makefile +3 -2
index fadf554d9391..1f5ec9741e6d 100644
@@ -10,9 +10,10 @@ obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
 ccflags-y := -fPIC -fno-common -fno-builtin -fno-stack-protector
 ccflags-y += -DDISABLE_BRANCH_PROFILING
 
-ldflags-y = -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
+ldflags-$(CONFIG_CPU_ENDIAN_BE8) := --be8
+ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
 	    -z max-page-size=4096 -z common-page-size=4096 \
-	    -nostdlib -shared \
+	    -nostdlib -shared $(ldflags-y) \
 	    $(call ld-option, --hash-style=sysv) \
 	    $(call ld-option, --build-id) \
 	    -T
Signature · 1 line
2.21.0
#1 lore raw

Hi Jason,

Thanks for catching this.

Quoted 5 lines · Jason A. Donenfeld

The commit fe00e50b2db8 ("ARM: 8858/1: vdso: use $(LD) instead of $(CC) to link VDSO") removed the passing of CFLAGS, since ld doesn't take those directly. However, prior, big-endian ARM was relying on gcc to translate its -mbe8 option into ld's --be8 option. Lacking this, ld

'git grep -- -mbe8' has no hit.

Is it a toolchain internal flag?

Quoted 32 lines

generated be32 code, making the VDSO generate SIGILL when called by userspace.

This commit passes --be8 if CONFIG_CPU_ENDIAN_BE8 is enabled.

Cc Masahiro Yamada <[email protected]>
Cc Russell King <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Ard Biesheuvel <[email protected]>
---
 arch/arm/vdso/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/vdso/Makefile +3 -3
index fadf554d9391..1f5ec9741e6d 100644
@@ -10,9 +10,10 @@ obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
 ccflags-y := -fPIC -fno-common -fno-builtin -fno-stack-protector
 ccflags-y += -DDISABLE_BRANCH_PROFILING
 
-ldflags-y = -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
+ldflags-$(CONFIG_CPU_ENDIAN_BE8) := --be8
+ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
            -z max-page-size=4096 -z common-page-size=4096 \
-           -nostdlib -shared \
+           -nostdlib -shared $(ldflags-y) \
            $(call ld-option, --hash-style=sysv) \
            $(call ld-option, --build-id) \
            -T
--
Quoted 2 lines

2.21.0

--
Best Regards
Masahiro Yamada

#2 lore raw

Hey Masahiro,

I'm not sure exactly. I did just notice another place --be8 is being added:

ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
LDFLAGS_vmlinux += --be8
KBUILD_LDFLAGS_MODULE += --be8
endif

I suppose it's possible that this is kbuild related where one of those isn't winding up in the right place. I did see that the commit that this patch addresses uses "=" instead of the more usual ":=" or "+=" for whatever reason.

Jason

#3 lore raw

Hi.

Quoted 4 lines · Jason A. Donenfeld

Hey Masahiro,

I'm not sure exactly. I did just notice another place --be8 is being added:

That is not my question.

I just asked about your commit log:
"big-endian ARM was relying on gcc to translate its -mbe8 option into ld's --be8 option"

I grepped '-mbe8', but I did not see it anywhere in the source tree.

So, I just wondered where it came from.

Quoted 11 lines

ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
LDFLAGS_vmlinux += --be8
KBUILD_LDFLAGS_MODULE += --be8
endif

I suppose it's possible that this is kbuild related where one of those isn't winding up in the right place. I did see that the commit that this patch addresses uses "=" instead of the more usual ":=" or "+=" for whatever reason.

Jason

Perhaps, the following will be cleaner:

ldflags-$(CONFIG_CPU_ENDIAN_BE8) += --be8

ldflags-y += -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
            -z max-page-size=4096 -z common-page-size=4096 \
            -nostdlib -shared \
            $(call ld-option, --hash-style=sysv) \
            $(call ld-option, --build-id) \
            -T

I think this fix-up should be applied by Russell. Please note he does not pick up patches directly from ML. To ask him to pick up patches, you need to put patches into his patch tracker. ([email protected])

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw
In reply to Masahiro Yamada
Quoted 6 lines · Masahiro Yamada

Hi Jason,

Thanks for catching this.

Quoted 1 line · Jason A. Donenfeld
Quoted 7 lines
Quoted 4 lines

The commit fe00e50b2db8 ("ARM: 8858/1: vdso: use $(LD) instead of $(CC) to link VDSO") removed the passing of CFLAGS, since ld doesn't take those directly. However, prior, big-endian ARM was relying on gcc to translate its -mbe8 option into ld's --be8 option. Lacking this, ld

'git grep -- -mbe8' has no hit.

It isn't -mbe8, it is --be8

$ arm-linux-gcc --target-help
...
  --be8                       Output BE8 format image
Quoted 45 lines

Is it a toolchain internal flag?

Quoted 32 lines

generated be32 code, making the VDSO generate SIGILL when called by userspace.

This commit passes --be8 if CONFIG_CPU_ENDIAN_BE8 is enabled.

Cc Masahiro Yamada <[email protected]>
Cc Russell King <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Ard Biesheuvel <[email protected]>
---
 arch/arm/vdso/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/vdso/Makefile +3 -3
index fadf554d9391..1f5ec9741e6d 100644
@@ -10,9 +10,10 @@ obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
 ccflags-y := -fPIC -fno-common -fno-builtin -fno-stack-protector
 ccflags-y += -DDISABLE_BRANCH_PROFILING
 
-ldflags-y = -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
+ldflags-$(CONFIG_CPU_ENDIAN_BE8) := --be8
+ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
            -z max-page-size=4096 -z common-page-size=4096 \
-           -nostdlib -shared \
+           -nostdlib -shared $(ldflags-y) \
            $(call ld-option, --hash-style=sysv) \
            $(call ld-option, --build-id) \
            -T
--
Quoted 2 lines

2.21.0

--
Best Regards
Masahiro Yamada

Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up
#5 lore raw
In reply to Jason A. Donenfeld

Hey Masahiro,

Considering ARM big endian userland is pretty badly broken without this, we should probably have this merged in the next rc or rather soon. Was there additional information you needed? Would you prefer Russell queues up my patch or did you want to make further build system changes?

Jason