vdso: Improve cmd_vdso_check to check all dynamic relocations
Subsystems (12)
PATCH 1/1 vdso: Improve cmd_vdso_check to check all dynamic relocations
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. powerpc64le ld as of 2.38 has the issue with defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.
With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missing R_AARCH64_RELATIVE.)
While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU grep 3.7.
--- arch/arm/vdso/Makefile | 3 --- arch/arm64/kernel/vdso/Makefile | 3 --- arch/arm64/kernel/vdso32/Makefile | 3 --- arch/csky/kernel/vdso/Makefile | 3 --- arch/loongarch/vdso/Makefile | 3 --- arch/mips/vdso/Makefile | 3 --- arch/powerpc/kernel/vdso/Makefile | 1 - arch/riscv/kernel/vdso/Makefile | 3 --- arch/s390/kernel/vdso32/Makefile | 2 -- arch/s390/kernel/vdso64/Makefile | 2 -- arch/x86/entry/vdso/Makefile | 4 ---- lib/vdso/Makefile | 13 ++++--------- 12 files changed, 4 insertions(+), 39 deletions(-)
arch/arm/vdso/Makefile +0 -3
@@ -1,8 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32 include $(srctree)/lib/vdso/Makefile hostprogs := vdsomunge
arch/arm64/kernel/vdso/Makefile +0 -3
@@ -6,9 +6,6 @@ # Heavily based on the vDSO Makefiles for other archs. # -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_AARCH64_JUMP_SLOT|R_AARCH64_GLOB_DAT|R_AARCH64_ABS64 include $(srctree)/lib/vdso/Makefile obj-vdso := vgettimeofday.o note.o sigreturn.o
arch/arm64/kernel/vdso32/Makefile +0 -3
@@ -3,9 +3,6 @@ # Makefile for vdso32 # -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32 include $(srctree)/lib/vdso/Makefile # Same as cc-*option, but using CC_COMPAT instead of CC
arch/csky/kernel/vdso/Makefile +0 -3
@@ -1,8 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOT include $(srctree)/lib/vdso/Makefile # Symbols present in the vdso
arch/loongarch/vdso/Makefile +0 -3
@@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Objects to go into the VDSO. -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_LARCH_32|R_LARCH_64|R_LARCH_MARK_LA|R_LARCH_JUMP_SLOT include $(srctree)/lib/vdso/Makefile obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o sigreturn.o
arch/mips/vdso/Makefile +0 -3
@@ -4,9 +4,6 @@ # Sanitizer runtimes are unavailable and cannot be linked here. KCSAN_SANITIZE := n -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_MIPS_JUMP_SLOT|R_MIPS_GLOB_DAT include $(srctree)/lib/vdso/Makefile obj-vdso-y := elf.o vgettimeofday.o sigreturn.o
arch/powerpc/kernel/vdso/Makefile +0 -1
@@ -2,7 +2,6 @@ # List of files in the vdso, has to be asm only for now -ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24 include $(srctree)/lib/vdso/Makefile obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o note-32.o getcpu-32.o
arch/riscv/kernel/vdso/Makefile +0 -3
@@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only # Copied from arch/tile/kernel/vdso/Makefile -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT include $(srctree)/lib/vdso/Makefile # Symbols present in the vdso vdso-syms = rt_sigreturn
arch/s390/kernel/vdso32/Makefile +0 -2
@@ -2,8 +2,6 @@ # List of files in the vdso KCOV_INSTRUMENT := n -ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE -ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT include $(srctree)/lib/vdso/Makefile obj-vdso32 = vdso_user_wrapper-32.o note-32.o
arch/s390/kernel/vdso64/Makefile +0 -2
@@ -2,8 +2,6 @@ # List of files in the vdso KCOV_INSTRUMENT := n -ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE -ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT include $(srctree)/lib/vdso/Makefile obj-vdso64 = vdso_user_wrapper.o note.o
arch/x86/entry/vdso/Makefile +0 -4
@@ -3,10 +3,6 @@ # Building vDSO images for x86. # -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_X86_64_JUMP_SLOT|R_X86_64_GLOB_DAT|R_X86_64_RELATIVE| -ARCH_REL_TYPE_ABS += R_386_GLOB_DAT|R_386_JMP_SLOT|R_386_RELATIVE include $(srctree)/lib/vdso/Makefile # Sanitizer runtimes are unavailable and cannot be linked here.
lib/vdso/Makefile +4 -9
@@ -5,18 +5,13 @@ GENERIC_VDSO_DIR := $(dir $(GENERIC_VDSO_MK_PATH)) c-gettimeofday-$(CONFIG_GENERIC_GETTIMEOFDAY) := $(addprefix $(GENERIC_VDSO_DIR), gettimeofday.c) -# This cmd checks that the vdso library does not contain absolute relocation +# This cmd checks that the vdso library does not contain dynamic relocations. # It has to be called after the linking of the vdso library and requires it # as a parameter. # -# $(ARCH_REL_TYPE_ABS) is defined in the arch specific makefile and corresponds -# to the absolute relocation types printed by "objdump -R" and accepted by the -# dynamic linker. -ifndef ARCH_REL_TYPE_ABS -$(error ARCH_REL_TYPE_ABS is not set) -endif - +# As a workaround for some GNU ld ports which produce unneeded R_*_NONE +# dynamic relocations, ignore R_*_NONE. quiet_cmd_vdso_check = VDSOCHK $@ - cmd_vdso_check = if $(OBJDUMP) -R $@ | egrep -h "$(ARCH_REL_TYPE_ABS)"; \ + cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q " R_\w*_"; \ then (echo >&2 "$@: dynamic relocations are not supported"; \ rm -f $@; /bin/false); fi
Signature · 1 line
2.37.2.672.g94769d06f0-goog
Quoted 12 lines · Fangrui Song
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. powerpc64le ld as of 2.38 has the issue with defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.
With the change, we can remove
ARCH_REL_TYPE_ABS.ARCH_REL_TYPE_ABSis a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missingR_AARCH64_RELATIVE.)
Quoted 7 lines
While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU grep 3.7.
Signed-off-by Fangrui Song <[email protected]>---
[...]
Ping.
Quoted 17 lines · Fangrui Song
Quoted 15 lines · Fangrui Song
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. powerpc64le ld as of 2.38 has the issue with defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.
With the change, we can remove
ARCH_REL_TYPE_ABS.ARCH_REL_TYPE_ABSis a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missingR_AARCH64_RELATIVE.)While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU grep 3.7.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Fangrui Song <[email protected]>---
[...]Ping.
Ping^2 :)
Le 28/09/2022 à 07:25, Fangrui Song a écrit :
Quoted 18 lines · Fangrui Song
Quoted 17 lines · Fangrui Song
Quoted 15 lines
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. powerpc64le ld as of 2.38 has the issue with defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.
With the change, we can remove
ARCH_REL_TYPE_ABS.ARCH_REL_TYPE_ABSis a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missingR_AARCH64_RELATIVE.)While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU grep 3.7.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Signed-off-by Fangrui Song <[email protected]>---
[...]Ping.
Ping^2 :)
Can you explain which ARCH_REL_TYPE_ABS can be removed with this change ? How is the verification done if ARCH_REL_TYPE_ABS is removed ?
Quoted 26 lines · Christophe Leroy
Le 28/09/2022 à 07:25, Fangrui Song a écrit :
Quoted 23 lines · Fangrui Song
Quoted 22 lines · Fangrui Song
Quoted 19 lines
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. powerpc64le ld as of 2.38 has the issue with defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.
With the change, we can remove
ARCH_REL_TYPE_ABS.ARCH_REL_TYPE_ABSis a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missingR_AARCH64_RELATIVE.)While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU grep 3.7.
Signed-off-by Fangrui Song <[email protected]>---
[...]
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Ping.
Ping^2 :)
Can you explain which
ARCH_REL_TYPE_ABScan be removed with this change ? How is the verification done ifARCH_REL_TYPE_ABSis removed ?
All ARCH_REL_TYPE_ABS relocation types can be removed. As explained, the real intention is to check no dynamic relocation, and this is done by the new
cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q "R_\w*_"; \
in this patch.
grep -v _NONE is to work around some GNU ld ports (and likely older releases of some ports even if their latest versions are fixed) which produce unneeded R_*_NONE dynamic relocations.
Quoted 39 lines · Fangrui Song
Quoted 26 lines · Christophe Leroy
Quoted 23 lines · Fangrui Song
Quoted 22 lines · Fangrui Song
Quoted 19 lines · Fangrui Song
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. powerpc64le ld as of 2.38 has the issue with defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.
With the change, we can remove
ARCH_REL_TYPE_ABS.ARCH_REL_TYPE_ABSis a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missingR_AARCH64_RELATIVE.)While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU grep 3.7.
Signed-off-by Fangrui Song <[email protected]>---
[...]Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Ping.
Ping^2 :)
Can you explain which
ARCH_REL_TYPE_ABScan be removed with this change ? How is the verification done ifARCH_REL_TYPE_ABSis removed ?All
ARCH_REL_TYPE_ABSrelocation types can be removed. As explained, the real intention is to check no dynamic relocation, and this is done by the new
Quoted 7 lines
cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q "R_\w*_"; \in this patch.
grep -v
_NONEis to work around some GNU ld ports (and likely older releases of some ports even if their latest versions are fixed) which produce unneeded R_*_NONE dynamic relocations.
Ping :)
Christophe Leroy
Reviewed-byLe 04/12/2022 à 05:50, Fangrui Song a écrit :
Quoted 31 lines · Fangrui Song
Quoted 30 lines · Christophe Leroy
Quoted 28 lines · Fangrui Song
Quoted 25 lines · Fangrui Song
Quoted 23 lines · Fangrui Song
Quoted 12 lines
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. powerpc64le ld as of 2.38 has the issue with defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.
With the change, we can remove
ARCH_REL_TYPE_ABS.ARCH_REL_TYPE_ABSis a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missingR_AARCH64_RELATIVE.)Quoted 7 lines
While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU grep 3.7.
Signed-off-by Fangrui Song <[email protected]>---
[...]Ping.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Ping^2 :)
Can you explain which
ARCH_REL_TYPE_ABScan be removed with this change ? How is the verification done ifARCH_REL_TYPE_ABSis removed ?All
ARCH_REL_TYPE_ABSrelocation types can be removed. As explained, the real intention is to check no dynamic relocation, and this is done by the new
Well, there was a typo in my question, I wanted to ask 'why', not 'which'.
Quoted 10 lines
Quoted 8 lines
cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q "R_\w*_"; \in this patch.
grep -v
_NONEis to work around some GNU ld ports (and likely older releases of some ports even if their latest versions are fixed) which produce unneeded R_*_NONE dynamic relocations.Ping :)
Ok, that seems to work on powerpc.
Quoted 55 lines · Christophe Leroy
Quoted 31 lines · Fangrui Song
Quoted 30 lines · Fangrui Song
Quoted 28 lines · Christophe Leroy
Quoted 25 lines · Fangrui Song
Quoted 23 lines · Fangrui Song
Quoted 12 lines · Fangrui Song
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. powerpc64le ld as of 2.38 has the issue with defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.
With the change, we can remove
ARCH_REL_TYPE_ABS.ARCH_REL_TYPE_ABSis a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missingR_AARCH64_RELATIVE.)Quoted 7 lines
While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU grep 3.7.
Signed-off-by Fangrui Song <[email protected]>---
[...]Ping.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Ping^2 :)
Can you explain which
ARCH_REL_TYPE_ABScan be removed with this change ? How is the verification done ifARCH_REL_TYPE_ABSis removed ?All
ARCH_REL_TYPE_ABSrelocation types can be removed. As explained, the real intention is to check no dynamic relocation, and this is done by the newWell, there was a typo in my question, I wanted to ask 'why', not 'which'.
Quoted 9 lines
Quoted 8 lines
cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q "R_\w*_"; \in this patch.
grep -v
_NONEis to work around some GNU ld ports (and likely older releases of some ports even if their latest versions are fixed) which produce unneeded R_*_NONE dynamic relocations.
Quoted 5 lines
Quoted 1 line
Ping :)
Ok, that seems to work on powerpc.
Reviewed-by Christophe Leroy <[email protected]>
Thanks. Can a maintainer pick up this commit?
PATCH v2 1/1 vdso: Improve cmd_vdso_check to check all dynamic relocations
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port fails to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. ld's powerpc port recently fixed
https://sourceware.org/bugzilla/show_bug.cgi?id=29540) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.
With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missing R_AARCH64_RELATIVE.)
---
Change from v1:
* rebase after 8ac3b5cd3e0521d92f9755e90d140382fc292510 (lib/vdso: use "grep -E" instead of "egrep")
* change the commit message to mention an example GNU ld bug; no longer say the patch fixes a deprecated egrep use
--- arch/arm/vdso/Makefile | 3 --- arch/arm64/kernel/vdso/Makefile | 3 --- arch/arm64/kernel/vdso32/Makefile | 3 --- arch/csky/kernel/vdso/Makefile | 3 --- arch/loongarch/vdso/Makefile | 3 --- arch/mips/vdso/Makefile | 3 --- arch/powerpc/kernel/vdso/Makefile | 1 - arch/riscv/kernel/vdso/Makefile | 3 --- arch/s390/kernel/vdso32/Makefile | 2 -- arch/s390/kernel/vdso64/Makefile | 2 -- arch/x86/entry/vdso/Makefile | 4 ---- lib/vdso/Makefile | 13 ++++--------- 12 files changed, 4 insertions(+), 39 deletions(-)
arch/arm/vdso/Makefile +0 -3
@@ -1,8 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32 include $(srctree)/lib/vdso/Makefile hostprogs := vdsomunge
arch/arm64/kernel/vdso/Makefile +0 -3
@@ -6,9 +6,6 @@ # Heavily based on the vDSO Makefiles for other archs. # -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_AARCH64_JUMP_SLOT|R_AARCH64_GLOB_DAT|R_AARCH64_ABS64 include $(srctree)/lib/vdso/Makefile obj-vdso := vgettimeofday.o note.o sigreturn.o
arch/arm64/kernel/vdso32/Makefile +0 -3
@@ -3,9 +3,6 @@ # Makefile for vdso32 # -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32 include $(srctree)/lib/vdso/Makefile # Same as cc-*option, but using CC_COMPAT instead of CC
arch/csky/kernel/vdso/Makefile +0 -3
@@ -1,8 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOT include $(srctree)/lib/vdso/Makefile # Symbols present in the vdso
arch/loongarch/vdso/Makefile +0 -3
@@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Objects to go into the VDSO. -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_LARCH_32|R_LARCH_64|R_LARCH_MARK_LA|R_LARCH_JUMP_SLOT include $(srctree)/lib/vdso/Makefile obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o sigreturn.o
arch/mips/vdso/Makefile +0 -3
@@ -4,9 +4,6 @@ # Sanitizer runtimes are unavailable and cannot be linked here. KCSAN_SANITIZE := n -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_MIPS_JUMP_SLOT|R_MIPS_GLOB_DAT include $(srctree)/lib/vdso/Makefile obj-vdso-y := elf.o vgettimeofday.o sigreturn.o
arch/powerpc/kernel/vdso/Makefile +0 -1
@@ -2,7 +2,6 @@ # List of files in the vdso, has to be asm only for now -ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24 include $(srctree)/lib/vdso/Makefile obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o note-32.o getcpu-32.o
arch/riscv/kernel/vdso/Makefile +0 -3
@@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only # Copied from arch/tile/kernel/vdso/Makefile -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT include $(srctree)/lib/vdso/Makefile # Symbols present in the vdso vdso-syms = rt_sigreturn
arch/s390/kernel/vdso32/Makefile +0 -2
@@ -2,8 +2,6 @@ # List of files in the vdso KCOV_INSTRUMENT := n -ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE -ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT include $(srctree)/lib/vdso/Makefile obj-vdso32 = vdso_user_wrapper-32.o note-32.o
arch/s390/kernel/vdso64/Makefile +0 -2
@@ -2,8 +2,6 @@ # List of files in the vdso KCOV_INSTRUMENT := n -ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE -ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT include $(srctree)/lib/vdso/Makefile obj-vdso64 = vdso_user_wrapper.o note.o
arch/x86/entry/vdso/Makefile +0 -4
@@ -3,10 +3,6 @@ # Building vDSO images for x86. # -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_X86_64_JUMP_SLOT|R_X86_64_GLOB_DAT|R_X86_64_RELATIVE| -ARCH_REL_TYPE_ABS += R_386_GLOB_DAT|R_386_JMP_SLOT|R_386_RELATIVE include $(srctree)/lib/vdso/Makefile # Sanitizer runtimes are unavailable and cannot be linked here.
lib/vdso/Makefile +4 -9
@@ -5,18 +5,13 @@ GENERIC_VDSO_DIR := $(dir $(GENERIC_VDSO_MK_PATH)) c-gettimeofday-$(CONFIG_GENERIC_GETTIMEOFDAY) := $(addprefix $(GENERIC_VDSO_DIR), gettimeofday.c) -# This cmd checks that the vdso library does not contain absolute relocation +# This cmd checks that the vdso library does not contain dynamic relocations. # It has to be called after the linking of the vdso library and requires it # as a parameter. # -# $(ARCH_REL_TYPE_ABS) is defined in the arch specific makefile and corresponds -# to the absolute relocation types printed by "objdump -R" and accepted by the -# dynamic linker. -ifndef ARCH_REL_TYPE_ABS -$(error ARCH_REL_TYPE_ABS is not set) -endif - +# As a workaround for some GNU ld ports which produce unneeded R_*_NONE +# dynamic relocations, ignore R_*_NONE. quiet_cmd_vdso_check = VDSOCHK $@ - cmd_vdso_check = if $(OBJDUMP) -R $@ | grep -E -h "$(ARCH_REL_TYPE_ABS)"; \ + cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q " R_\w*_"; \ then (echo >&2 "$@: dynamic relocations are not supported"; \ rm -f $@; /bin/false); fi
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Quoted 32 lines · On Wed, 21 Dec 2022 15:51:47 PST (-0800), [email protected] wrote:
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port fails to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. ld's powerpc port recently fixed
https://sourceware.org/bugzilla/show_bug.cgi?id=29540) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.With the change, we can remove
ARCH_REL_TYPE_ABS.ARCH_REL_TYPE_ABSis a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missingR_AARCH64_RELATIVE.)Signed-off-by Fangrui Song <[email protected]>Reviewed-by Christophe Leroy <[email protected]>---
Change from v1:
* rebase after8ac3b5cd3e0521d92f9755e90d140382fc292510(lib/vdso: use "grep -E" instead of "egrep")
* change the commit message to mention an example GNU ld bug; no longer say the patch fixes a deprecated egrep use--- arch/arm/vdso/Makefile | 3 --- arch/arm64/kernel/vdso/Makefile | 3 --- arch/arm64/kernel/vdso32/Makefile | 3 --- arch/csky/kernel/vdso/Makefile | 3 --- arch/loongarch/vdso/Makefile | 3 --- arch/mips/vdso/Makefile | 3 --- arch/powerpc/kernel/vdso/Makefile | 1 - arch/riscv/kernel/vdso/Makefile | 3 --- arch/s390/kernel/vdso32/Makefile | 2 -- arch/s390/kernel/vdso64/Makefile | 2 -- arch/x86/entry/vdso/Makefile | 4 ---- lib/vdso/Makefile | 13 ++++--------- 12 files changed, 4 insertions(+), 39 deletions(-)
[snip]
Quoted 5 lines
arch/riscv/kernel/vdso/Makefile +0
-0
arch/riscv/kernel/vdso/Makefile line 6
Quoted 9 lines
arch/riscv/kernel/vdso/Makefile +0
-3@@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only # Copied from arch/tile/kernel/vdso/Makefile -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT include $(srctree)/lib/vdso/Makefile # Symbols present in the vdso vdso-syms = rt_sigreturn
Thanks!
Quoted 54 lines · Palmer Dabbelt
Quoted 32 lines · On Wed, 21 Dec 2022 15:51:47 PST (-0800), [email protected] wrote:
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port fails to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. ld's powerpc port recently fixed
https://sourceware.org/bugzilla/show_bug.cgi?id=29540) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.With the change, we can remove
ARCH_REL_TYPE_ABS.ARCH_REL_TYPE_ABSis a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missingR_AARCH64_RELATIVE.)Signed-off-by Fangrui Song <[email protected]>Reviewed-by Christophe Leroy <[email protected]>---
Change from v1:
* rebase after8ac3b5cd3e0521d92f9755e90d140382fc292510(lib/vdso: use "grep -E" instead of "egrep")
* change the commit message to mention an example GNU ld bug; no longer say the patch fixes a deprecated egrep use--- arch/arm/vdso/Makefile | 3 --- arch/arm64/kernel/vdso/Makefile | 3 --- arch/arm64/kernel/vdso32/Makefile | 3 --- arch/csky/kernel/vdso/Makefile | 3 --- arch/loongarch/vdso/Makefile | 3 --- arch/mips/vdso/Makefile | 3 --- arch/powerpc/kernel/vdso/Makefile | 1 - arch/riscv/kernel/vdso/Makefile | 3 --- arch/s390/kernel/vdso32/Makefile | 2 -- arch/s390/kernel/vdso64/Makefile | 2 -- arch/x86/entry/vdso/Makefile | 4 ---- lib/vdso/Makefile | 13 ++++--------- 12 files changed, 4 insertions(+), 39 deletions(-)[snip]
Quoted 5 lines
arch/riscv/kernel/vdso/Makefile +0
-0arch/riscv/kernel/vdso/Makefile line 6
Quoted 9 lines
arch/riscv/kernel/vdso/Makefile +0
-3@@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only # Copied from arch/tile/kernel/vdso/Makefile -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT include $(srctree)/lib/vdso/Makefile # Symbols present in the vdso vdso-syms = rt_sigreturn
Quoted 1 line
Thanks!
Looks like this patch hasn't been picked yet...
Quoted 62 lines · Fangrui Song
Quoted 3 lines · Palmer Dabbelt
Quoted 1 line · On Wed, 21 Dec 2022 15:51:47 PST (-0800), [email protected] wrote:
The actual intention is that no dynamic relocation exists. However,
some
Quoted 7 lines
Quoted 7 lines
GNU ld ports produce unneeded R_*_NONE. (If a port fails to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. ld's powerpc port recently fixed
https://sourceware.org/bugzilla/show_bug.cgi?id=29540) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.With the change, we can remove
ARCH_REL_TYPE_ABS.ARCH_REL_TYPE_ABSisa
Quoted 9 lines
Quoted 9 lines
bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missing
R_AARCH64_RELATIVE.)Signed-off-by Fangrui Song <[email protected]>Reviewed-by Christophe Leroy <[email protected]>---
Change from v1:
* rebase after8ac3b5cd3e0521d92f9755e90d140382fc292510(lib/vdso: use"grep -E" instead of "egrep")
Quoted 1 line
Quoted 1 line
* change the commit message to mention an example GNU ld bug; no
longer say the patch fixes a deprecated egrep use
Quoted 15 lines
Quoted 6 lines
--- arch/arm/vdso/Makefile | 3 --- arch/arm64/kernel/vdso/Makefile | 3 --- arch/arm64/kernel/vdso32/Makefile | 3 --- arch/csky/kernel/vdso/Makefile | 3 --- arch/loongarch/vdso/Makefile | 3 ---Quoted 8 lines
arch/mips/vdso/Makefile | 3 --- arch/powerpc/kernel/vdso/Makefile | 1 - arch/riscv/kernel/vdso/Makefile | 3 --- arch/s390/kernel/vdso32/Makefile | 2 -- arch/s390/kernel/vdso64/Makefile | 2 -- arch/x86/entry/vdso/Makefile | 4 ---- lib/vdso/Makefile | 13 ++++--------- 12 files changed, 4 insertions(+), 39 deletions(-)Quoted 3 lines
[snip]
Review
Quoted 1 line
(quoted diff) +0
-0b/arch/riscv/kernel/vdso/Makefile
Quoted 8 lines
arch/riscv/kernel/vdso/Makefile line 4
Quoted 8 lines
index
06e6b27f3bcc..d85c37e11b21100644arch/riscv/kernel/vdso/Makefile +0
-1@@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only # Copied from arch/tile/kernel/vdso/Makefile -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be definedbefore
Quoted 8 lines
arch/riscv/kernel/vdso/Makefile line 6
Quoted 5 lines
arch/riscv/kernel/vdso/Makefile +0
-2-# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT include $(srctree)/lib/vdso/Makefile # Symbols present in the vdso vdso-syms = rt_sigreturn
Quoted 4 lines
Quoted 1 line
Thanks!
Looks like this patch hasn't been picked yet...
Ping:)
Signature · 1 line
宋方睿
Hi Fangrui,
Apologize for the delay, I totally missed that you had a new version of your patch since it was threaded with the old one.
Quoted 11 lines · Fangrui Song
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port fails to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. ld's powerpc port recently fixed
https://sourceware.org/bugzilla/show_bug.cgi?id=29540) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.With the change, we can remove
ARCH_REL_TYPE_ABS.ARCH_REL_TYPE_ABSis a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missingR_AARCH64_RELATIVE.)
It makes sense to update the name, it started as "absolute relocations" but then it evolved into something else.
A part that, did you perform any testing with the generated vDSO libraries?
Quoted 31 lines
Signed-off-by Fangrui Song <[email protected]>Reviewed-by Christophe Leroy <[email protected]>---
Change from v1:
* rebase after8ac3b5cd3e0521d92f9755e90d140382fc292510(lib/vdso: use "grep -E" instead of "egrep")
* change the commit message to mention an example GNU ld bug; no longer say the patch fixes a deprecated egrep use
---
arch/arm/vdso/Makefile | 3 --- arch/arm64/kernel/vdso/Makefile | 3 ---arch/arm64/kernel/vdso32/Makefile| 3 --- arch/csky/kernel/vdso/Makefile | 3 --- arch/loongarch/vdso/Makefile | 3 ---
arch/mips/vdso/Makefile | 3 ---arch/powerpc/kernel/vdso/Makefile| 1 - arch/riscv/kernel/vdso/Makefile | 3 --- arch/s390/kernel/vdso32/Makefile | 2 -- arch/s390/kernel/vdso64/Makefile | 2 -- arch/x86/entry/vdso/Makefile | 4 ----
lib/vdso/Makefile | 13 ++++---------12 files changed, 4 insertions(+), 39 deletions(-)arch/arm/vdso/Makefile +0
-0@@ -1,8 +1,5 @@ # SPDX-License-Identifier: GPL-2.0
arch/arm/vdso/Makefile line 5
Quoted 3 lines
arch/arm/vdso/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
I would still add a comment here to say why we are including the generic Makefile to prevent that it gets accidentally removed (similar thing for every architecture touched by this patch).
With that:
Quoted 169 lines
include $(srctree)/lib/vdso/Makefile
hostprogs := vdsomungearch/arm64/kernel/vdso/Makefile +0
-0@@ -6,9 +6,6 @@ # Heavily based on the vDSO Makefiles for other archs. #arch/arm64/kernel/vdso/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_AARCH64_JUMP_SLOT|R_AARCH64_GLOB_DAT|R_AARCH64_ABS64include $(srctree)/lib/vdso/Makefile
obj-vdso := vgettimeofday.o note.o sigreturn.oarch/arm64/kernel/vdso32/Makefile +0
-0@@ -3,9 +3,6 @@ # Makefile for vdso32 #arch/arm64/kernel/vdso32/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32include $(srctree)/lib/vdso/Makefile
# Same as cc-*option, but usingCC_COMPATinstead of CCarch/csky/kernel/vdso/Makefile +0
-0@@ -1,8 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-onlyarch/csky/kernel/vdso/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOTinclude $(srctree)/lib/vdso/Makefile
# Symbols present in the vdsoarch/loongarch/vdso/Makefile +0
-0@@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Objects to go into the VDSO.arch/loongarch/vdso/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_LARCH_32|R_LARCH_64|R_LARCH_MARK_LA|R_LARCH_JUMP_SLOTinclude $(srctree)/lib/vdso/Makefile
obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o sigreturn.oarch/mips/vdso/Makefile +0
-0@@ -4,9 +4,6 @@ # Sanitizer runtimes are unavailable and cannot be linked here.KCSAN_SANITIZE := n
arch/mips/vdso/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_MIPS_JUMP_SLOT|R_MIPS_GLOB_DATinclude $(srctree)/lib/vdso/Makefile
obj-vdso-y := elf.o vgettimeofday.o sigreturn.oarch/powerpc/kernel/vdso/Makefile +0
-0@@ -2,7 +2,6 @@
# List of files in the vdso, has to be asm only for now
-ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24 include $(srctree)/lib/vdso/Makefile
obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o
note-32.o getcpu-32.oarch/riscv/kernel/vdso/Makefile +0
-0@@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only # Copied from arch/tile/kernel/vdso/Makefilearch/riscv/kernel/vdso/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOTinclude $(srctree)/lib/vdso/Makefile
# Symbols present in the vdso
vdso-syms =rt_sigreturnarch/s390/kernel/vdso32/Makefile +0
-0@@ -2,8 +2,6 @@ # List of files in the vdso
KCOV_INSTRUMENT := narch/s390/kernel/vdso32/Makefile +0
-2-ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE -ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
include $(srctree)/lib/vdso/Makefile
obj-vdso32 = vdso_user_wrapper-32.o note-32.oarch/s390/kernel/vdso64/Makefile +0
-0@@ -2,8 +2,6 @@ # List of files in the vdso
KCOV_INSTRUMENT := narch/s390/kernel/vdso64/Makefile +0
-2-ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE -ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
include $(srctree)/lib/vdso/Makefile
obj-vdso64 = vdso_user_wrapper.o note.oarch/x86/entry/vdso/Makefile +0
-0@@ -3,10 +3,6 @@ # Building vDSO images for x86. #arch/x86/entry/vdso/Makefile +0
-4-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_X86_64_JUMP_SLOT|R_X86_64_GLOB_DAT|R_X86_64_RELATIVE| -ARCH_REL_TYPE_ABS += R_386_GLOB_DAT|R_386_JMP_SLOT|R_386_RELATIVEinclude $(srctree)/lib/vdso/Makefile
# Sanitizer runtimes are unavailable and cannot be linked here.lib/vdso/Makefile +0
-0@@ -5,18 +5,13 @@ GENERIC_VDSO_DIR := $(dir $(GENERIC_VDSO_MK_PATH))
c-gettimeofday-$(CONFIG_GENERIC_GETTIMEOFDAY) := $(addprefix $(GENERIC_VDSO_DIR),gettimeofday.c)lib/vdso/Makefile +1
-1-# This cmd checks that the vdso library does not contain absolute relocation +# This cmd checks that the vdso library does not contain dynamic relocations.# It has to be called after the linking of the vdso library and requires it
# as a parameter. #lib/vdso/Makefile +2
-7-# $(ARCH_REL_TYPE_ABS) is defined in the arch specific makefile and corresponds -# to the absolute relocation types printed by "objdump -R" and accepted by the -# dynamic linker. -ifndef ARCH_REL_TYPE_ABS -$(error ARCH_REL_TYPE_ABS is not set) -endif - +# As a workaround for some GNU ld ports which produce unneeded R_*_NONE +# dynamic relocations, ignore R_*_NONE.quiet_cmd_vdso_check = VDSOCHK $@
-cmd_vdso_check= if $(OBJDUMP) -R $@ | grep -E -h "$(ARCH_REL_TYPE_ABS)"; \
+cmd_vdso_check= if $(READELF) -rW $@ | grep -v_NONE| grep -q " R_\w*_"; \
then (echo >&2 "$@: dynamic relocations are not supported"; \
rm -f $@;/bin/false); fi
Signature · 2 lines
Regards, Vincenzo
Quoted 4 lines · Vincenzo Frascino
Hi Fangrui,
Apologize for the delay, I totally missed that you had a new version of your patch since it was threaded with the old one.
Thank you! No worries.
Quoted 13 lines · Fangrui Song
Quoted 11 lines
The actual intention is that no dynamic relocation exists. However, some GNU ld ports produce unneeded R_*_NONE. (If a port fails to determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE relocations. E.g. ld's powerpc port recently fixed
https://sourceware.org/bugzilla/show_bug.cgi?id=29540) R_*_NONE are generally no-op in the dynamic loaders. So just ignore them.With the change, we can remove
ARCH_REL_TYPE_ABS.ARCH_REL_TYPE_ABSis a bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are not called "absolute relocations". (The patch is motivated by the arm64 port missingR_AARCH64_RELATIVE.)
Quoted 4 lines
It makes sense to update the name, it started as "absolute relocations" but then it evolved into something else.
A part that, did you perform any testing with the generated vDSO libraries?
I checked that the built vdso did not change (the patch just changes some post-link verification).
To be more sure, I used commands like
https://github.com/ClangBuiltLinux/tc-build/blob/main/kernel/build.sh#L305
to build a kernel and commands like
~/Dev/ClangBuiltLinux/boot-utils/boot-qemu.py -a arm64 -k /tmp/linux/arm64
to run an image for a couple of architectures.
The initrd images run some init scripts along with
# buildroot/overlay-poweroff/etc/init.d/S50yolo
cat /proc/version
poweroff
I think these have exercised vdso.
Quoted 39 lines
Quoted 31 lines
Signed-off-by Fangrui Song <[email protected]>Reviewed-by Christophe Leroy <[email protected]>---
Change from v1:
* rebase after8ac3b5cd3e0521d92f9755e90d140382fc292510(lib/vdso: use "grep -E" instead of "egrep")
* change the commit message to mention an example GNU ld bug; no longer say the patch fixes a deprecated egrep use
---
arch/arm/vdso/Makefile | 3 --- arch/arm64/kernel/vdso/Makefile | 3 ---arch/arm64/kernel/vdso32/Makefile| 3 --- arch/csky/kernel/vdso/Makefile | 3 --- arch/loongarch/vdso/Makefile | 3 ---
arch/mips/vdso/Makefile | 3 ---arch/powerpc/kernel/vdso/Makefile| 1 - arch/riscv/kernel/vdso/Makefile | 3 --- arch/s390/kernel/vdso32/Makefile | 2 -- arch/s390/kernel/vdso64/Makefile | 2 -- arch/x86/entry/vdso/Makefile | 4 ----
lib/vdso/Makefile | 13 ++++---------12 files changed, 4 insertions(+), 39 deletions(-)arch/arm/vdso/Makefile +0
-0@@ -1,8 +1,5 @@ # SPDX-License-Identifier: GPL-2.0arch/arm/vdso/Makefile line 5
Quoted 3 lines
arch/arm/vdso/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32I would still add a comment here to say why we are including the generic
Makefileto prevent that it gets accidentally removed (similar thing for every architecture touched by this patch).
Quoted 5 lines
With that:
Just sent v3
(https://lore.kernel.org/all/[email protected]/)
with the comment changes. Thanks!
Quoted 173 lines
Quoted 169 lines
include $(srctree)/lib/vdso/Makefile
hostprogs := vdsomungearch/arm64/kernel/vdso/Makefile +0
-0@@ -6,9 +6,6 @@ # Heavily based on the vDSO Makefiles for other archs. #arch/arm64/kernel/vdso/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_AARCH64_JUMP_SLOT|R_AARCH64_GLOB_DAT|R_AARCH64_ABS64include $(srctree)/lib/vdso/Makefile
obj-vdso := vgettimeofday.o note.o sigreturn.oarch/arm64/kernel/vdso32/Makefile +0
-0@@ -3,9 +3,6 @@ # Makefile for vdso32 #arch/arm64/kernel/vdso32/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32include $(srctree)/lib/vdso/Makefile
# Same as cc-*option, but usingCC_COMPATinstead of CCarch/csky/kernel/vdso/Makefile +0
-0@@ -1,8 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-onlyarch/csky/kernel/vdso/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOTinclude $(srctree)/lib/vdso/Makefile
# Symbols present in the vdsoarch/loongarch/vdso/Makefile +0
-0@@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Objects to go into the VDSO.arch/loongarch/vdso/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_LARCH_32|R_LARCH_64|R_LARCH_MARK_LA|R_LARCH_JUMP_SLOTinclude $(srctree)/lib/vdso/Makefile
obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o sigreturn.oarch/mips/vdso/Makefile +0
-0@@ -4,9 +4,6 @@ # Sanitizer runtimes are unavailable and cannot be linked here.KCSAN_SANITIZE := n
arch/mips/vdso/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_MIPS_JUMP_SLOT|R_MIPS_GLOB_DATinclude $(srctree)/lib/vdso/Makefile
obj-vdso-y := elf.o vgettimeofday.o sigreturn.oarch/powerpc/kernel/vdso/Makefile +0
-0@@ -2,7 +2,6 @@
# List of files in the vdso, has to be asm only for now
-ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24 include $(srctree)/lib/vdso/Makefile
obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o
note-32.o getcpu-32.oarch/riscv/kernel/vdso/Makefile +0
-0@@ -1,9 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only # Copied from arch/tile/kernel/vdso/Makefilearch/riscv/kernel/vdso/Makefile +0
-3-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOTinclude $(srctree)/lib/vdso/Makefile
# Symbols present in the vdso
vdso-syms =rt_sigreturnarch/s390/kernel/vdso32/Makefile +0
-0@@ -2,8 +2,6 @@ # List of files in the vdso
KCOV_INSTRUMENT := narch/s390/kernel/vdso32/Makefile +0
-2-ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE -ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
include $(srctree)/lib/vdso/Makefile
obj-vdso32 = vdso_user_wrapper-32.o note-32.oarch/s390/kernel/vdso64/Makefile +0
-0@@ -2,8 +2,6 @@ # List of files in the vdso
KCOV_INSTRUMENT := narch/s390/kernel/vdso64/Makefile +0
-2-ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE -ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
include $(srctree)/lib/vdso/Makefile
obj-vdso64 = vdso_user_wrapper.o note.oarch/x86/entry/vdso/Makefile +0
-0@@ -3,10 +3,6 @@ # Building vDSO images for x86. #arch/x86/entry/vdso/Makefile +0
-4-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before -# the inclusion of generic Makefile. -ARCH_REL_TYPE_ABS := R_X86_64_JUMP_SLOT|R_X86_64_GLOB_DAT|R_X86_64_RELATIVE| -ARCH_REL_TYPE_ABS += R_386_GLOB_DAT|R_386_JMP_SLOT|R_386_RELATIVEinclude $(srctree)/lib/vdso/Makefile
# Sanitizer runtimes are unavailable and cannot be linked here.lib/vdso/Makefile +0
-0@@ -5,18 +5,13 @@ GENERIC_VDSO_DIR := $(dir $(GENERIC_VDSO_MK_PATH))
c-gettimeofday-$(CONFIG_GENERIC_GETTIMEOFDAY) := $(addprefix $(GENERIC_VDSO_DIR),gettimeofday.c)lib/vdso/Makefile +1
-1-# This cmd checks that the vdso library does not contain absolute relocation +# This cmd checks that the vdso library does not contain dynamic relocations.# It has to be called after the linking of the vdso library and requires it
# as a parameter. #lib/vdso/Makefile +2
-7-# $(ARCH_REL_TYPE_ABS) is defined in the arch specific makefile and corresponds -# to the absolute relocation types printed by "objdump -R" and accepted by the -# dynamic linker. -ifndef ARCH_REL_TYPE_ABS -$(error ARCH_REL_TYPE_ABS is not set) -endif - +# As a workaround for some GNU ld ports which produce unneeded R_*_NONE +# dynamic relocations, ignore R_*_NONE.quiet_cmd_vdso_check = VDSOCHK $@
-cmd_vdso_check= if $(OBJDUMP) -R $@ | grep -E -h "$(ARCH_REL_TYPE_ABS)"; \
+cmd_vdso_check= if $(READELF) -rW $@ | grep -v_NONE| grep -q " R_\w*_"; \
then (echo >&2 "$@: dynamic relocations are not supported"; \
rm -f $@;/bin/false); fiSignature · 2 lines
Regards, Vincenzo