diff options
author | Florin Sarbu <samentu1@gmail.com> | 2017-11-13 21:00:11 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-12-11 22:02:58 +0000 |
commit | 6d7fe76005e4dac1678b59dd790ce5cd6cbe9dde (patch) | |
tree | d9b790d3395de34ae189cd490c7420baee762fed | |
parent | 8f7b65de9964fe5ab360511c9e031112067c6de0 (diff) | |
download | poky-6d7fe76005e4dac1678b59dd790ce5cd6cbe9dde.tar.gz |
gcc: Use libssp_nonshared linker specs only for ppc/musl
Link libssp_nonshared.a only for ppc/musl because glibc already
provides the content for libssp_nonshared in libc_nonshared.a and
therefore we dont need to make it universal.
(From OE-Core rev: c08247e3c7c004a40281d4010186a9ace86e0e47)
(From OE-Core rev: ac2aad028daca6ea3aa0c0ccea8d528e896f8349)
Signed-off-by: Florin Sarbu <florin@resin.io>
Signed-off-by: Armin Kuster <akuster@mvista.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
3 files changed, 88 insertions, 29 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-6.3.inc b/meta/recipes-devtools/gcc/gcc-6.3.inc index d74f12c466..5c81a33af0 100644 --- a/meta/recipes-devtools/gcc/gcc-6.3.inc +++ b/meta/recipes-devtools/gcc/gcc-6.3.inc | |||
@@ -71,7 +71,7 @@ SRC_URI = "\ | |||
71 | file://0038-Search-target-sysroot-gcc-version-specific-dirs-with.patch \ | 71 | file://0038-Search-target-sysroot-gcc-version-specific-dirs-with.patch \ |
72 | file://0039-Fix-various-_FOR_BUILD-and-related-variables.patch \ | 72 | file://0039-Fix-various-_FOR_BUILD-and-related-variables.patch \ |
73 | file://0040-nios2-Define-MUSL_DYNAMIC_LINKER.patch \ | 73 | file://0040-nios2-Define-MUSL_DYNAMIC_LINKER.patch \ |
74 | file://0041-ssp_nonshared.patch \ | 74 | file://0041-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \ |
75 | file://0042-gcc-libcpp-support-ffile-prefix-map-old-new.patch \ | 75 | file://0042-gcc-libcpp-support-ffile-prefix-map-old-new.patch \ |
76 | file://0043-Reuse-fdebug-prefix-map-to-replace-ffile-prefix-map.patch \ | 76 | file://0043-Reuse-fdebug-prefix-map-to-replace-ffile-prefix-map.patch \ |
77 | file://0044-gcc-final.c-fdebug-prefix-map-support-to-remap-sourc.patch \ | 77 | file://0044-gcc-final.c-fdebug-prefix-map-support-to-remap-sourc.patch \ |
diff --git a/meta/recipes-devtools/gcc/gcc-6.3/0041-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch b/meta/recipes-devtools/gcc/gcc-6.3/0041-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch new file mode 100644 index 0000000000..29b7ce72d2 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-6.3/0041-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch | |||
@@ -0,0 +1,87 @@ | |||
1 | From 210f6b3b82084cc756e02b8bc12f909a43b14ee8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Tue, 27 Jun 2017 18:10:54 -0700 | ||
4 | Subject: [PATCH 40/49] Add ssp_nonshared to link commandline for musl targets | ||
5 | |||
6 | when -fstack-protector options are enabled we need to | ||
7 | link with ssp_shared on musl since it does not provide | ||
8 | the __stack_chk_fail_local() so essentially it provides | ||
9 | libssp but not libssp_nonshared something like | ||
10 | TARGET_LIBC_PROVIDES_SSP_BUT_NOT_SSP_NONSHARED | ||
11 | where-as for glibc the needed symbols | ||
12 | are already present in libc_nonshared library therefore | ||
13 | we do not need any library helper on glibc based systems | ||
14 | but musl needs the libssp_noshared from gcc | ||
15 | |||
16 | Upstream-Status: Pending | ||
17 | |||
18 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
19 | --- | ||
20 | gcc/config/linux.h | 7 +++++++ | ||
21 | gcc/config/rs6000/linux.h | 10 ++++++++++ | ||
22 | gcc/config/rs6000/linux64.h | 10 ++++++++++ | ||
23 | 3 files changed, 27 insertions(+) | ||
24 | |||
25 | diff --git a/gcc/config/linux.h b/gcc/config/linux.h | ||
26 | index 2e683d0c430..1b4df798671 100644 | ||
27 | --- a/gcc/config/linux.h | ||
28 | +++ b/gcc/config/linux.h | ||
29 | @@ -182,6 +182,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | ||
30 | { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ | ||
31 | { 0, 0, 0, 0, 0, 0 } \ | ||
32 | } | ||
33 | +#ifdef TARGET_LIBC_PROVIDES_SSP | ||
34 | +#undef LINK_SSP_SPEC | ||
35 | +#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ | ||
36 | + "|fstack-protector-strong|fstack-protector-explicit" \ | ||
37 | + ":-lssp_nonshared}" | ||
38 | +#endif | ||
39 | + | ||
40 | #endif | ||
41 | |||
42 | #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */ | ||
43 | diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h | ||
44 | index 684afd6c190..22cfa391b89 100644 | ||
45 | --- a/gcc/config/rs6000/linux.h | ||
46 | +++ b/gcc/config/rs6000/linux.h | ||
47 | @@ -91,6 +91,16 @@ | ||
48 | " -m elf32ppclinux") | ||
49 | #endif | ||
50 | |||
51 | +/* link libssp_nonshared.a with musl */ | ||
52 | +#if DEFAULT_LIBC == LIBC_MUSL | ||
53 | +#ifdef TARGET_LIBC_PROVIDES_SSP | ||
54 | +#undef LINK_SSP_SPEC | ||
55 | +#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ | ||
56 | + "|fstack-protector-strong|fstack-protector-explicit" \ | ||
57 | + ":-lssp_nonshared}" | ||
58 | +#endif | ||
59 | +#endif | ||
60 | + | ||
61 | #undef LINK_OS_LINUX_SPEC | ||
62 | #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \ | ||
63 | %{rdynamic:-export-dynamic} \ | ||
64 | diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h | ||
65 | index 3b00ec0fcf0..8371f8d7b6b 100644 | ||
66 | --- a/gcc/config/rs6000/linux64.h | ||
67 | +++ b/gcc/config/rs6000/linux64.h | ||
68 | @@ -465,6 +465,16 @@ extern int dot_symbols; | ||
69 | " -m elf64ppc") | ||
70 | #endif | ||
71 | |||
72 | +/* link libssp_nonshared.a with musl */ | ||
73 | +#if DEFAULT_LIBC == LIBC_MUSL | ||
74 | +#ifdef TARGET_LIBC_PROVIDES_SSP | ||
75 | +#undef LINK_SSP_SPEC | ||
76 | +#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ | ||
77 | + "|fstack-protector-strong|fstack-protector-explicit" \ | ||
78 | + ":-lssp_nonshared}" | ||
79 | +#endif | ||
80 | +#endif | ||
81 | + | ||
82 | #define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \ | ||
83 | %{rdynamic:-export-dynamic} \ | ||
84 | -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}} \ | ||
85 | -- | ||
86 | 2.13.2 | ||
87 | |||
diff --git a/meta/recipes-devtools/gcc/gcc-6.3/0041-ssp_nonshared.patch b/meta/recipes-devtools/gcc/gcc-6.3/0041-ssp_nonshared.patch deleted file mode 100644 index 0744529741..0000000000 --- a/meta/recipes-devtools/gcc/gcc-6.3/0041-ssp_nonshared.patch +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | From 551a5db7acb56e085a101f1c222d51b2c1b039a4 Mon Sep 17 00:00:00 2001 | ||
2 | From: Szabolcs Nagy <nsz@port70.net> | ||
3 | Date: Sat, 7 Nov 2015 14:58:40 +0000 | ||
4 | Subject: [PATCH 41/46] ssp_nonshared | ||
5 | |||
6 | --- | ||
7 | Upstream-Status: Inappropriate [OE Configuration] | ||
8 | |||
9 | gcc/gcc.c | 3 ++- | ||
10 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/gcc/gcc.c b/gcc/gcc.c | ||
13 | index 2812819..9de96ee 100644 | ||
14 | --- a/gcc/gcc.c | ||
15 | +++ b/gcc/gcc.c | ||
16 | @@ -863,7 +863,8 @@ proper position among the other output files. */ | ||
17 | #ifndef LINK_SSP_SPEC | ||
18 | #ifdef TARGET_LIBC_PROVIDES_SSP | ||
19 | #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ | ||
20 | - "|fstack-protector-strong|fstack-protector-explicit:}" | ||
21 | + "|fstack-protector-strong|fstack-protector-explicit" \ | ||
22 | + ":-lssp_nonshared}" | ||
23 | #else | ||
24 | #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ | ||
25 | "|fstack-protector-strong|fstack-protector-explicit" \ | ||
26 | -- | ||
27 | 2.8.2 | ||
28 | |||