Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

powerpc/vdso: Improve linker flags

When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, there
are several warnings in the PowerPC vDSO:

clang-16: error: -Wl,-soname=linux-vdso32.so.1: 'linker' input unused [-Werror,-Wunused-command-line-argument]
clang-16: error: -Wl,--hash-style=both: 'linker' input unused [-Werror,-Wunused-command-line-argument]
clang-16: error: argument unused during compilation: '-shared' [-Werror,-Wunused-command-line-argument]

clang-16: error: argument unused during compilation: '-nostdinc' [-Werror,-Wunused-command-line-argument]
clang-16: error: argument unused during compilation: '-Wa,-maltivec' [-Werror,-Wunused-command-line-argument]

The first group of warnings point out that linker flags were being added
to all invocations of $(CC), even though they will only be used during
the final vDSO link. Move those flags to ldflags-y.

The second group of warnings are compiler or assembler flags that will
be unused during linking. Filter them out from KBUILD_CFLAGS so that
they are not used during linking.

Additionally, '-z noexecstack' was added directly to the ld_and_check
rule in commit 1d53c0192b15 ("powerpc/vdso: link with -z noexecstack")
but now that there is a common ldflags variable, it can be moved there.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
Tested-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Nathan Chancellor and committed by
Masahiro Yamada
f0a42fba 024734d1

+11 -7
+11 -7
arch/powerpc/kernel/vdso/Makefile
··· 47 47 UBSAN_SANITIZE := n 48 48 KASAN_SANITIZE := n 49 49 50 - ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both 51 - ccflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld) 50 + ccflags-y := -fno-common -fno-builtin 51 + ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack 52 + ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld) 53 + # Filter flags that clang will warn are unused for linking 54 + ldflags-y += $(filter-out $(CC_FLAGS_FTRACE) -Wa$(comma)%, $(KBUILD_CFLAGS)) 52 55 53 - CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32 56 + CC32FLAGS := -m32 57 + LD32FLAGS := -Wl,-soname=linux-vdso32.so.1 54 58 AS32FLAGS := -D__VDSO32__ 55 59 56 - CC64FLAGS := -Wl,-soname=linux-vdso64.so.1 60 + LD64FLAGS := -Wl,-soname=linux-vdso64.so.1 57 61 AS64FLAGS := -D__VDSO64__ 58 62 59 63 targets += vdso32.lds ··· 96 92 97 93 # actual build commands 98 94 quiet_cmd_vdso32ld_and_check = VDSO32L $@ 99 - cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check) 95 + cmd_vdso32ld_and_check = $(VDSOCC) $(ldflags-y) $(CC32FLAGS) $(LD32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check) 100 96 quiet_cmd_vdso32as = VDSO32A $@ 101 97 cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $< 102 98 quiet_cmd_vdso32cc = VDSO32C $@ 103 99 cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $< 104 100 105 101 quiet_cmd_vdso64ld_and_check = VDSO64L $@ 106 - cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check) 102 + cmd_vdso64ld_and_check = $(VDSOCC) $(ldflags-y) $(LD64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check) 107 103 quiet_cmd_vdso64as = VDSO64A $@ 108 - cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $< 104 + cmd_vdso64as = $(VDSOCC) $(a_flags) $(AS64FLAGS) -c -o $@ $< 109 105 110 106 OBJECT_FILES_NON_STANDARD := y