aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linaro.org>2018-10-03 23:59:21 +0200
committerAníbal Limón <anibal.limon@linaro.org>2018-10-03 17:11:33 -0500
commit7e7f09b731ac8ec09cc87ed058908c8479b8c7ab (patch)
treed6815f376474e41b29aa00665abac776d6354cf9
parent66772742dc783df5fd2f1ef28de20e2b4d6ee31d (diff)
gcc-linaro-7.*: Only use gcc libssp linker flags when build for musl
GLibc provides there own version for libssp to support -fstack-protector so only use linker flags when build for musl. Backport see, http://git.openembedded.org/openembedded-core/commit/?id=d71eba26850838b2878efea3f8c392a2eb2ebbfb Fixed oe-rpb master builds failing in perl, https://ci.linaro.org/job/96boards-reference-platform-openembedded-master/DISTRO=rpb,MACHINE=hikey,label=docker-stretch-amd64/761/console Change-Id: I82ad7fa86df6ed56512891c20e43e62418a53f61 Signed-off-by: Aníbal Limón <anibal.limon@linaro.org>
-rw-r--r--meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1.inc2
-rw-r--r--meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1/0040-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch87
-rw-r--r--meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1/0040-ssp_nonshared.patch28
-rw-r--r--meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2.inc2
-rw-r--r--meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2/0040-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch87
-rw-r--r--meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2/0040-ssp_nonshared.patch28
6 files changed, 176 insertions, 58 deletions
diff --git a/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1.inc b/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1.inc
index 602dbe79..9e069ebb 100644
--- a/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1.inc
+++ b/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1.inc
@@ -65,7 +65,7 @@ SRC_URI = "\
file://0037-Search-target-sysroot-gcc-version-specific-dirs-with.patch \
file://0038-Fix-various-_FOR_BUILD-and-related-variables.patch \
file://0039-nios2-Define-MUSL_DYNAMIC_LINKER.patch \
- file://0040-ssp_nonshared.patch \
+ file://0040-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \
file://0041-gcc-libcpp-support-ffile-prefix-map-old-new.patch \
file://0042-Reuse-fdebug-prefix-map-to-replace-ffile-prefix-map.patch \
file://0043-gcc-final.c-fdebug-prefix-map-support-to-remap-sourc.patch \
diff --git a/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1/0040-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch b/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1/0040-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
new file mode 100644
index 00000000..29b7ce72
--- /dev/null
+++ b/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1/0040-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
@@ -0,0 +1,87 @@
+From 210f6b3b82084cc756e02b8bc12f909a43b14ee8 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 27 Jun 2017 18:10:54 -0700
+Subject: [PATCH 40/49] Add ssp_nonshared to link commandline for musl targets
+
+when -fstack-protector options are enabled we need to
+link with ssp_shared on musl since it does not provide
+the __stack_chk_fail_local() so essentially it provides
+libssp but not libssp_nonshared something like
+TARGET_LIBC_PROVIDES_SSP_BUT_NOT_SSP_NONSHARED
+ where-as for glibc the needed symbols
+are already present in libc_nonshared library therefore
+we do not need any library helper on glibc based systems
+but musl needs the libssp_noshared from gcc
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ gcc/config/linux.h | 7 +++++++
+ gcc/config/rs6000/linux.h | 10 ++++++++++
+ gcc/config/rs6000/linux64.h | 10 ++++++++++
+ 3 files changed, 27 insertions(+)
+
+diff --git a/gcc/config/linux.h b/gcc/config/linux.h
+index 2e683d0c430..1b4df798671 100644
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -182,6 +182,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
+ { 0, 0, 0, 0, 0, 0 } \
+ }
++#ifdef TARGET_LIBC_PROVIDES_SSP
++#undef LINK_SSP_SPEC
++#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
++ "|fstack-protector-strong|fstack-protector-explicit" \
++ ":-lssp_nonshared}"
++#endif
++
+ #endif
+
+ #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
+diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
+index 684afd6c190..22cfa391b89 100644
+--- a/gcc/config/rs6000/linux.h
++++ b/gcc/config/rs6000/linux.h
+@@ -91,6 +91,16 @@
+ " -m elf32ppclinux")
+ #endif
+
++/* link libssp_nonshared.a with musl */
++#if DEFAULT_LIBC == LIBC_MUSL
++#ifdef TARGET_LIBC_PROVIDES_SSP
++#undef LINK_SSP_SPEC
++#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
++ "|fstack-protector-strong|fstack-protector-explicit" \
++ ":-lssp_nonshared}"
++#endif
++#endif
++
+ #undef LINK_OS_LINUX_SPEC
+ #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \
+ %{rdynamic:-export-dynamic} \
+diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
+index 3b00ec0fcf0..8371f8d7b6b 100644
+--- a/gcc/config/rs6000/linux64.h
++++ b/gcc/config/rs6000/linux64.h
+@@ -465,6 +465,16 @@ extern int dot_symbols;
+ " -m elf64ppc")
+ #endif
+
++/* link libssp_nonshared.a with musl */
++#if DEFAULT_LIBC == LIBC_MUSL
++#ifdef TARGET_LIBC_PROVIDES_SSP
++#undef LINK_SSP_SPEC
++#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
++ "|fstack-protector-strong|fstack-protector-explicit" \
++ ":-lssp_nonshared}"
++#endif
++#endif
++
+ #define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \
+ %{rdynamic:-export-dynamic} \
+ -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}} \
+--
+2.13.2
+
diff --git a/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1/0040-ssp_nonshared.patch b/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1/0040-ssp_nonshared.patch
deleted file mode 100644
index e9fb35cb..00000000
--- a/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.1/0040-ssp_nonshared.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 6c98538411ac30c2262b2635547974c6cd1699c5 Mon Sep 17 00:00:00 2001
-From: Szabolcs Nagy <nsz@port70.net>
-Date: Sat, 7 Nov 2015 14:58:40 +0000
-Subject: [PATCH 40/47] ssp_nonshared
-
----
-Upstream-Status: Inappropriate [OE-Specific]
-
- gcc/gcc.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/gcc/gcc.c b/gcc/gcc.c
-index 84af5d5a2e1..2c6471aa565 100644
---- a/gcc/gcc.c
-+++ b/gcc/gcc.c
-@@ -872,7 +872,8 @@ proper position among the other output files. */
- #ifndef LINK_SSP_SPEC
- #ifdef TARGET_LIBC_PROVIDES_SSP
- #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
-- "|fstack-protector-strong|fstack-protector-explicit:}"
-+ "|fstack-protector-strong|fstack-protector-explicit" \
-+ ":-lssp_nonshared}"
- #else
- #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
- "|fstack-protector-strong|fstack-protector-explicit" \
---
-2.12.2
-
diff --git a/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2.inc b/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2.inc
index 63a66b44..39f5391e 100644
--- a/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2.inc
+++ b/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2.inc
@@ -66,7 +66,7 @@ SRC_URI = "\
file://0037-Search-target-sysroot-gcc-version-specific-dirs-with.patch \
file://0038-Fix-various-_FOR_BUILD-and-related-variables.patch \
file://0039-nios2-Define-MUSL_DYNAMIC_LINKER.patch \
- file://0040-ssp_nonshared.patch \
+ file://0040-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \
file://0041-gcc-libcpp-support-ffile-prefix-map-old-new.patch \
file://0042-Reuse-fdebug-prefix-map-to-replace-ffile-prefix-map.patch \
file://0043-gcc-final.c-fdebug-prefix-map-support-to-remap-sourc.patch \
diff --git a/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2/0040-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch b/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2/0040-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
new file mode 100644
index 00000000..29b7ce72
--- /dev/null
+++ b/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2/0040-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
@@ -0,0 +1,87 @@
+From 210f6b3b82084cc756e02b8bc12f909a43b14ee8 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 27 Jun 2017 18:10:54 -0700
+Subject: [PATCH 40/49] Add ssp_nonshared to link commandline for musl targets
+
+when -fstack-protector options are enabled we need to
+link with ssp_shared on musl since it does not provide
+the __stack_chk_fail_local() so essentially it provides
+libssp but not libssp_nonshared something like
+TARGET_LIBC_PROVIDES_SSP_BUT_NOT_SSP_NONSHARED
+ where-as for glibc the needed symbols
+are already present in libc_nonshared library therefore
+we do not need any library helper on glibc based systems
+but musl needs the libssp_noshared from gcc
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ gcc/config/linux.h | 7 +++++++
+ gcc/config/rs6000/linux.h | 10 ++++++++++
+ gcc/config/rs6000/linux64.h | 10 ++++++++++
+ 3 files changed, 27 insertions(+)
+
+diff --git a/gcc/config/linux.h b/gcc/config/linux.h
+index 2e683d0c430..1b4df798671 100644
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -182,6 +182,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
+ { 0, 0, 0, 0, 0, 0 } \
+ }
++#ifdef TARGET_LIBC_PROVIDES_SSP
++#undef LINK_SSP_SPEC
++#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
++ "|fstack-protector-strong|fstack-protector-explicit" \
++ ":-lssp_nonshared}"
++#endif
++
+ #endif
+
+ #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
+diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
+index 684afd6c190..22cfa391b89 100644
+--- a/gcc/config/rs6000/linux.h
++++ b/gcc/config/rs6000/linux.h
+@@ -91,6 +91,16 @@
+ " -m elf32ppclinux")
+ #endif
+
++/* link libssp_nonshared.a with musl */
++#if DEFAULT_LIBC == LIBC_MUSL
++#ifdef TARGET_LIBC_PROVIDES_SSP
++#undef LINK_SSP_SPEC
++#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
++ "|fstack-protector-strong|fstack-protector-explicit" \
++ ":-lssp_nonshared}"
++#endif
++#endif
++
+ #undef LINK_OS_LINUX_SPEC
+ #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \
+ %{rdynamic:-export-dynamic} \
+diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
+index 3b00ec0fcf0..8371f8d7b6b 100644
+--- a/gcc/config/rs6000/linux64.h
++++ b/gcc/config/rs6000/linux64.h
+@@ -465,6 +465,16 @@ extern int dot_symbols;
+ " -m elf64ppc")
+ #endif
+
++/* link libssp_nonshared.a with musl */
++#if DEFAULT_LIBC == LIBC_MUSL
++#ifdef TARGET_LIBC_PROVIDES_SSP
++#undef LINK_SSP_SPEC
++#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
++ "|fstack-protector-strong|fstack-protector-explicit" \
++ ":-lssp_nonshared}"
++#endif
++#endif
++
+ #define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \
+ %{rdynamic:-export-dynamic} \
+ -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}} \
+--
+2.13.2
+
diff --git a/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2/0040-ssp_nonshared.patch b/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2/0040-ssp_nonshared.patch
deleted file mode 100644
index e9fb35cb..00000000
--- a/meta-linaro-toolchain/recipes-devtools/gcc/gcc-linaro-7.2/0040-ssp_nonshared.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 6c98538411ac30c2262b2635547974c6cd1699c5 Mon Sep 17 00:00:00 2001
-From: Szabolcs Nagy <nsz@port70.net>
-Date: Sat, 7 Nov 2015 14:58:40 +0000
-Subject: [PATCH 40/47] ssp_nonshared
-
----
-Upstream-Status: Inappropriate [OE-Specific]
-
- gcc/gcc.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/gcc/gcc.c b/gcc/gcc.c
-index 84af5d5a2e1..2c6471aa565 100644
---- a/gcc/gcc.c
-+++ b/gcc/gcc.c
-@@ -872,7 +872,8 @@ proper position among the other output files. */
- #ifndef LINK_SSP_SPEC
- #ifdef TARGET_LIBC_PROVIDES_SSP
- #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
-- "|fstack-protector-strong|fstack-protector-explicit:}"
-+ "|fstack-protector-strong|fstack-protector-explicit" \
-+ ":-lssp_nonshared}"
- #else
- #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
- "|fstack-protector-strong|fstack-protector-explicit" \
---
-2.12.2
-