From 0feb88c6154f8b37e148c2a0c27137572192475c Mon Sep 17 00:00:00 2001 From: Andrii Nakryiko Date: Wed, 24 Aug 2022 11:25:02 +0800 Subject: [PATCH] selftests/bpf: Pass sanitizer flags to linker through LDFLAGS mainline inclusion from mainline-5.17-rc1 commit 2a2cb45b727b7a1041f3d3d93414b774e66454bb category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2a2cb45b727b7a1041f3d3d93414b774e66454bb ------------------------------------------------- When adding -fsanitize=address to SAN_CFLAGS, it has to be passed both to compiler through CFLAGS as well as linker through LDFLAGS. Add SAN_CFLAGS into LDFLAGS to allow building selftests with ASAN. Signed-off-by: Andrii Nakryiko Signed-off-by: Alexei Starovoitov Reviewed-by: Hengqi Chen Link: https://lore.kernel.org/bpf/20211107165521.9240-2-andrii@kernel.org (cherry picked from commit 2a2cb45b727b7a1041f3d3d93414b774e66454bb) Signed-off-by: Wang Yufen Conflicts: tools/testing/selftests/bpf/Makefile Signed-off-by: Wang Yufen --- tools/testing/selftests/bpf/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index f3353f7bdedf..1529e52344e2 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -26,6 +26,7 @@ CFLAGS += -g -rdynamic -Wall -O2 $(GENFLAGS) $(SAN_CFLAGS) \ -I$(TOOLSINCDIR) -I$(APIDIR) -I$(OUTPUT) \ -Dbpf_prog_load=bpf_prog_test_load \ -Dbpf_load_program=bpf_test_load_program +LDFLAGS += $(SAN_CFLAGS) LDLIBS += -lcap -lelf -lz -lrt -lpthread # Order correspond to 'make run_tests' order -- GitLab