kernel: make the LoongArch vDSO build id independent of the build path

The LoongArch vDSO Makefile builds its objects with a flag set of its own,
in the same way as the MIPS one. It drops -ffile-prefix-map, adds -g and
links with --build-id, so the build id of the vDSO follows the absolute
path of the build directory. The kernel embeds the vDSO, so two builds in
different directories produce different images.

Take the prefix map flags over from KBUILD_CFLAGS.

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin committed 2026-09-22 18:46:30 +02:00
1 parent 0995a0e351
commit 115209aa22
2 files changed
+86

No files matched your search

@@ -0,0 +1,43 @@
From: John Crispin <john@phrozen.org>
Subject: LoongArch: vdso: keep the prefix map flags of the kernel build
The vDSO Makefile builds its objects with a flag set of its own. It takes
a few flags from KBUILD_CFLAGS and adds -g, so the vDSO always carries
debug information, even when the kernel does not.
-ffile-prefix-map and -fdebug-prefix-map are not in the list of flags that
the Makefile takes over. DW_AT_comp_dir of the vDSO objects therefore holds
the absolute path of the build directory.
The vDSO is linked with --build-id, so the linker hashes the debug
information as well. objcopy -S then removes the debug information and
keeps the note. The result is a vDSO image with identical code and a build
ID that depends on the build directory. The kernel embeds that image, so
the kernel and every firmware image built from it differ between two builds
in different directories.
Take the two prefix map flags over from KBUILD_CFLAGS. ccflags-vdso feeds
both cflags-vdso and aflags-vdso, so the C objects and the assembler
objects are covered. GCC forwards the flags to the assembler, so the
-Wa,-gdwarf-2 output is covered too.
A filter pattern holds at most one %, so each flag name needs its own
filter. -fmacro-prefix-map does not change the debug information and is
left out.
Signed-off-by: John Crispin <john@phrozen.org>
---
arch/loongarch/vdso/Makefile | 2 ++
1 file changed, 2 insertions(+)
--- a/arch/loongarch/vdso/Makefile
+++ b/arch/loongarch/vdso/Makefile
@@ -13,6 +13,8 @@ ccflags-vdso := \
$(filter -E%,$(KBUILD_CFLAGS)) \
$(filter -march=%,$(KBUILD_CFLAGS)) \
$(filter -m%-float,$(KBUILD_CFLAGS)) \
+ $(filter -ffile-prefix-map=%,$(KBUILD_CFLAGS)) \
+ $(filter -fdebug-prefix-map=%,$(KBUILD_CFLAGS)) \
$(CLANG_FLAGS) \
-D__VDSO__
@@ -0,0 +1,43 @@
From: John Crispin <john@phrozen.org>
Subject: LoongArch: vdso: keep the prefix map flags of the kernel build
The vDSO Makefile builds its objects with a flag set of its own. It takes
a few flags from KBUILD_CFLAGS and adds -g, so the vDSO always carries
debug information, even when the kernel does not.
-ffile-prefix-map and -fdebug-prefix-map are not in the list of flags that
the Makefile takes over. DW_AT_comp_dir of the vDSO objects therefore holds
the absolute path of the build directory.
The vDSO is linked with --build-id, so the linker hashes the debug
information as well. objcopy -S then removes the debug information and
keeps the note. The result is a vDSO image with identical code and a build
ID that depends on the build directory. The kernel embeds that image, so
the kernel and every firmware image built from it differ between two builds
in different directories.
Take the two prefix map flags over from KBUILD_CFLAGS. ccflags-vdso feeds
both cflags-vdso and aflags-vdso, so the C objects and the assembler
objects are covered. GCC forwards the flags to the assembler, so the
-Wa,-gdwarf-2 output is covered too.
A filter pattern holds at most one %, so each flag name needs its own
filter. -fmacro-prefix-map does not change the debug information and is
left out.
Signed-off-by: John Crispin <john@phrozen.org>
---
arch/loongarch/vdso/Makefile | 2 ++
1 file changed, 2 insertions(+)
--- a/arch/loongarch/vdso/Makefile
+++ b/arch/loongarch/vdso/Makefile
@@ -13,6 +13,8 @@ ccflags-vdso := \
$(filter -E%,$(KBUILD_CFLAGS)) \
$(filter -march=%,$(KBUILD_CFLAGS)) \
$(filter -m%-float,$(KBUILD_CFLAGS)) \
+ $(filter -ffile-prefix-map=%,$(KBUILD_CFLAGS)) \
+ $(filter -fdebug-prefix-map=%,$(KBUILD_CFLAGS)) \
$(CLANG_FLAGS) \
-D__VDSO__