]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.105/selftests-seccomp-use-ldlibs-instead-of-ldflags.patch
Linux 4.9.162
[thirdparty/kernel/stable-queue.git] / releases / 4.14.105 / selftests-seccomp-use-ldlibs-instead-of-ldflags.patch
1 From a2a8d0da8b3521411e5bb48c4971cf59904691ca Mon Sep 17 00:00:00 2001
2 From: Fathi Boudra <fathi.boudra@linaro.org>
3 Date: Wed, 16 Jan 2019 11:43:19 -0600
4 Subject: selftests: seccomp: use LDLIBS instead of LDFLAGS
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 [ Upstream commit 5bbc73a841d7f0bbe025a342146dde462a796a5a ]
10
11 seccomp_bpf fails to build due to undefined reference errors:
12
13 aarch64-linaro-linux-gcc --sysroot=/build/tmp-rpb-glibc/sysroots/hikey
14 -O2 -pipe -g -feliminate-unused-debug-types -Wl,-no-as-needed -Wall
15 -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lpthread seccomp_bpf.c -o
16 /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf
17 /tmp/ccrlR3MW.o: In function `tsync_sibling':
18 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1920: undefined reference to `sem_post'
19 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1920: undefined reference to `sem_post'
20 /tmp/ccrlR3MW.o: In function `TSYNC_setup':
21 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1863: undefined reference to `sem_init'
22 /tmp/ccrlR3MW.o: In function `TSYNC_teardown':
23 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1904: undefined reference to `sem_destroy'
24 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1897: undefined reference to `pthread_kill'
25 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1898: undefined reference to `pthread_cancel'
26 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1899: undefined reference to `pthread_join'
27 /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
28 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
29 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
30 /tmp/ccrlR3MW.o: In function `TSYNC_siblings_fail_prctl':
31 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1978: undefined reference to `sem_wait'
32 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1990: undefined reference to `pthread_join'
33 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1992: undefined reference to `pthread_join'
34 /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
35 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
36 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
37 /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_with_ancestor':
38 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2016: undefined reference to `sem_wait'
39 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2032: undefined reference to `pthread_join'
40 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2034: undefined reference to `pthread_join'
41 /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
42 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
43 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
44 /tmp/ccrlR3MW.o: In function `TSYNC_two_sibling_want_nnp':
45 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2046: undefined reference to `sem_wait'
46 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2058: undefined reference to `pthread_join'
47 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2060: undefined reference to `pthread_join'
48 /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
49 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
50 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
51 /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_with_no_filter':
52 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2073: undefined reference to `sem_wait'
53 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2098: undefined reference to `pthread_join'
54 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2100: undefined reference to `pthread_join'
55 /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
56 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
57 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
58 /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_with_one_divergence':
59 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2125: undefined reference to `sem_wait'
60 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2143: undefined reference to `pthread_join'
61 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2145: undefined reference to `pthread_join'
62 /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
63 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
64 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
65 /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_not_under_filter':
66 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2169: undefined reference to `sem_wait'
67 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2202: undefined reference to `pthread_join'
68 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2227: undefined reference to `pthread_join'
69 /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
70 /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
71
72 It's GNU Make and linker specific.
73
74 The default Makefile rule looks like:
75
76 $(CC) $(CFLAGS) $(LDFLAGS) $@ $^ $(LDLIBS)
77
78 When linking is done by gcc itself, no issue, but when it needs to be passed
79 to proper ld, only LDLIBS follows and then ld cannot know what libs to link
80 with.
81
82 More detail:
83 https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
84
85 LDFLAGS
86 Extra flags to give to compilers when they are supposed to invoke the linker,
87 ‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable
88 instead.
89
90 LDLIBS
91 Library flags or names given to compilers when they are supposed to invoke the
92 linker, ‘ld’. LOADLIBES is a deprecated (but still supported) alternative to
93 LDLIBS. Non-library linker flags, such as -L, should go in the LDFLAGS
94 variable.
95
96 https://lkml.org/lkml/2010/2/10/362
97
98 tools/perf: libraries must come after objects
99
100 Link order matters, use LDLIBS instead of LDFLAGS to properly link against
101 libpthread.
102
103 Signed-off-by: Fathi Boudra <fathi.boudra@linaro.org>
104 Acked-by: Kees Cook <keescook@chromium.org>
105 Signed-off-by: Shuah Khan <shuah@kernel.org>
106 Signed-off-by: Sasha Levin <sashal@kernel.org>
107 ---
108 tools/testing/selftests/seccomp/Makefile | 2 +-
109 1 file changed, 1 insertion(+), 1 deletion(-)
110
111 diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
112 index fce7f4ce06925..1760b3e397306 100644
113 --- a/tools/testing/selftests/seccomp/Makefile
114 +++ b/tools/testing/selftests/seccomp/Makefile
115 @@ -9,7 +9,7 @@ BINARIES := seccomp_bpf seccomp_benchmark
116 CFLAGS += -Wl,-no-as-needed -Wall
117
118 seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h
119 - $(CC) $(CFLAGS) $(LDFLAGS) -lpthread $< -o $@
120 + $(CC) $(CFLAGS) $(LDFLAGS) $< -lpthread -o $@
121
122 TEST_PROGS += $(BINARIES)
123 EXTRA_CLEAN := $(BINARIES)
124 --
125 2.19.1
126