diff options
author | Andre McCurdy <armccurdy@gmail.com> | 2018-05-16 18:03:53 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-05-29 21:07:12 +0100 |
commit | 568a1f74913d7524650015297648f51f85bc2809 (patch) | |
tree | a4638fbeac600b4615ee51e35cb1818864fccbc5 /meta/recipes-devtools/strace | |
parent | 0781c9fe7b2c31a208b63d344b5acf28a442f408 (diff) | |
download | poky-568a1f74913d7524650015297648f51f85bc2809.tar.gz |
strace: fix ARM Thumb build with frame pointers enabled
Replace the previous (incomplete) workaround with better solution
backported from upstream.
(From OE-Core rev: b038a6e418d723a0a413219e9882cdd7f3804625)
Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/strace')
-rw-r--r-- | meta/recipes-devtools/strace/strace/0001-linux-arm-raw_syscall.h-avoid-r7-specified-register-.patch | 74 | ||||
-rw-r--r-- | meta/recipes-devtools/strace/strace_4.22.bb | 16 |
2 files changed, 81 insertions, 9 deletions
diff --git a/meta/recipes-devtools/strace/strace/0001-linux-arm-raw_syscall.h-avoid-r7-specified-register-.patch b/meta/recipes-devtools/strace/strace/0001-linux-arm-raw_syscall.h-avoid-r7-specified-register-.patch new file mode 100644 index 0000000000..8584291ba8 --- /dev/null +++ b/meta/recipes-devtools/strace/strace/0001-linux-arm-raw_syscall.h-avoid-r7-specified-register-.patch | |||
@@ -0,0 +1,74 @@ | |||
1 | From 0c75ebaad09d6d3f2395dfe6160904af883dd0d9 Mon Sep 17 00:00:00 2001 | ||
2 | From: Andre McCurdy <armccurdy@gmail.com> | ||
3 | Date: Tue, 15 May 2018 15:34:39 -0700 | ||
4 | Subject: [PATCH] linux/arm/raw_syscall.h: avoid r7 specified register | ||
5 | variables with Thumb | ||
6 | |||
7 | If Thumb code is being generated and frame pointers are enabled, the | ||
8 | Thumb frame pointer in r7 clashes with any local variable which may | ||
9 | need to be assigned to r7 (e.g. the syscall NR when making a raw | ||
10 | syscall). | ||
11 | |||
12 | With gcc, the double use of r7 results in a build error, e.g. | ||
13 | |||
14 | strace-4.22/tests/inject-nf.c:86:1: error: r7 cannot be used in asm here | ||
15 | |||
16 | With clang, the double use of r7 can result in the compiler silently | ||
17 | generating broken code which crashes at run time due to frame pointer | ||
18 | corruption: | ||
19 | |||
20 | https://bugs.llvm.org/show_bug.cgi?id=34165 | ||
21 | |||
22 | In most cases the problem isn't visible as frame pointers will be | ||
23 | disabled automatically due to optimisation level. However to handle | ||
24 | cases where frame pointers are enabled (e.g. when CFLAGS etc are set | ||
25 | to support a debug build, etc) provide a version of raw_syscall_0 | ||
26 | which manually saves and restores the frame pointer value in r7 | ||
27 | to a temporary register before setting up the syscall NR in r7 | ||
28 | and invoking the syscall. | ||
29 | |||
30 | * linux/arm/raw_syscall.h (raw_syscall_0) [__thumb__]: Provide | ||
31 | an alternative version. | ||
32 | |||
33 | Upstream-Status: Backport | ||
34 | |||
35 | Signed-off-by: Andre McCurdy <armccurdy@gmail.com> | ||
36 | --- | ||
37 | linux/arm/raw_syscall.h | 15 +++++++++++++++ | ||
38 | 1 file changed, 15 insertions(+) | ||
39 | |||
40 | diff --git a/linux/arm/raw_syscall.h b/linux/arm/raw_syscall.h | ||
41 | index 69c7e23..ec534ec 100644 | ||
42 | --- a/linux/arm/raw_syscall.h | ||
43 | +++ b/linux/arm/raw_syscall.h | ||
44 | @@ -36,12 +36,27 @@ static inline kernel_ulong_t | ||
45 | raw_syscall_0(const kernel_ulong_t nr, kernel_ulong_t *err) | ||
46 | { | ||
47 | *err = 0; | ||
48 | + | ||
49 | +#ifdef __thumb__ /* && FRAME_POINTERS_ENABLED */ | ||
50 | + | ||
51 | + register kernel_ulong_t rt; | ||
52 | + register kernel_ulong_t r0 __asm__("r0"); | ||
53 | + __asm__ __volatile__("mov %1,r7; mov r7,%2; swi 0x0; mov r7,%1" | ||
54 | + : "=r"(r0), "=&r"(rt) | ||
55 | + : "r"(nr) | ||
56 | + : "memory"); | ||
57 | + | ||
58 | +#else | ||
59 | + | ||
60 | register kernel_ulong_t r7 __asm__("r7") = nr; | ||
61 | register kernel_ulong_t r0 __asm__("r0"); | ||
62 | __asm__ __volatile__("swi 0x0" | ||
63 | : "=r"(r0) | ||
64 | : "r"(r7) | ||
65 | : "memory"); | ||
66 | + | ||
67 | +#endif | ||
68 | + | ||
69 | return r0; | ||
70 | } | ||
71 | # define raw_syscall_0 raw_syscall_0 | ||
72 | -- | ||
73 | 1.9.1 | ||
74 | |||
diff --git a/meta/recipes-devtools/strace/strace_4.22.bb b/meta/recipes-devtools/strace/strace_4.22.bb index 947b3f7bf6..99691f87c3 100644 --- a/meta/recipes-devtools/strace/strace_4.22.bb +++ b/meta/recipes-devtools/strace/strace_4.22.bb | |||
@@ -14,21 +14,13 @@ SRC_URI = "https://strace.io/files/${PV}/strace-${PV}.tar.xz \ | |||
14 | file://mips-SIGEMT.patch \ | 14 | file://mips-SIGEMT.patch \ |
15 | file://0001-caps-abbrev.awk-fix-gawk-s-path.patch \ | 15 | file://0001-caps-abbrev.awk-fix-gawk-s-path.patch \ |
16 | file://0001-tests-sigaction-Check-for-mips-and-alpha-before-usin.patch \ | 16 | file://0001-tests-sigaction-Check-for-mips-and-alpha-before-usin.patch \ |
17 | file://0001-linux-arm-raw_syscall.h-avoid-r7-specified-register-.patch \ | ||
17 | " | 18 | " |
18 | SRC_URI[md5sum] = "7a2a7d7715da6e6834bc65bd09bace1c" | 19 | SRC_URI[md5sum] = "7a2a7d7715da6e6834bc65bd09bace1c" |
19 | SRC_URI[sha256sum] = "068cd09264c95e4d591bbcd3ea08f99a693ed8663cd5169b0fdad72eb5bdb39d" | 20 | SRC_URI[sha256sum] = "068cd09264c95e4d591bbcd3ea08f99a693ed8663cd5169b0fdad72eb5bdb39d" |
20 | 21 | ||
21 | inherit autotools ptest bluetooth | 22 | inherit autotools ptest bluetooth |
22 | 23 | ||
23 | EXTRA_OECONF += "--enable-mpers=no" | ||
24 | |||
25 | CFLAGS_append_libc-musl = " -Dsigcontext_struct=sigcontext" | ||
26 | # otherwise strace-4.22/tests/inject-nf.c fails to build as discussed here: | ||
27 | # http://lists.openembedded.org/pipermail/openembedded-core/2018-May/150647.html | ||
28 | DEBUG_OPTIMIZATION_remove = "${@bb.utils.contains('PTEST_ENABLED', '1', '-fno-omit-frame-pointer', '', d)}" | ||
29 | |||
30 | RDEPENDS_${PN}-ptest += "make coreutils grep gawk sed" | ||
31 | |||
32 | PACKAGECONFIG_class-target ??= "\ | 24 | PACKAGECONFIG_class-target ??= "\ |
33 | ${@bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez', '', d)} \ | 25 | ${@bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez', '', d)} \ |
34 | " | 26 | " |
@@ -36,6 +28,10 @@ PACKAGECONFIG_class-target ??= "\ | |||
36 | PACKAGECONFIG[bluez] = "ac_cv_header_bluetooth_bluetooth_h=yes,ac_cv_header_bluetooth_bluetooth_h=no,${BLUEZ}" | 28 | PACKAGECONFIG[bluez] = "ac_cv_header_bluetooth_bluetooth_h=yes,ac_cv_header_bluetooth_bluetooth_h=no,${BLUEZ}" |
37 | PACKAGECONFIG[libunwind] = "--with-libunwind,--without-libunwind,libunwind" | 29 | PACKAGECONFIG[libunwind] = "--with-libunwind,--without-libunwind,libunwind" |
38 | 30 | ||
31 | EXTRA_OECONF += "--enable-mpers=no" | ||
32 | |||
33 | CFLAGS_append_libc-musl = " -Dsigcontext_struct=sigcontext" | ||
34 | |||
39 | TESTDIR = "tests" | 35 | TESTDIR = "tests" |
40 | 36 | ||
41 | do_install_append() { | 37 | do_install_append() { |
@@ -61,5 +57,7 @@ do_install_ptest() { | |||
61 | ${D}/${PTEST_PATH}/${TESTDIR}/Makefile | 57 | ${D}/${PTEST_PATH}/${TESTDIR}/Makefile |
62 | } | 58 | } |
63 | 59 | ||
60 | RDEPENDS_${PN}-ptest += "make coreutils grep gawk sed" | ||
61 | |||
64 | BBCLASSEXTEND = "native" | 62 | BBCLASSEXTEND = "native" |
65 | TOOLCHAIN = "gcc" | 63 | TOOLCHAIN = "gcc" |