Skip to contentSkip to conversation

libunwind: Fix build with fstack-protector on musl

PATCH Superseded Khem Raj 2 participants 3 messages Mar 22, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 libunwind: Fix build with fstack-protector on musl

libunwind makery inserts -nostdlib during linking which fails the build on musl when security flags are enabled since it remove ssp from linking, so add them explicitly to SECURITY_LDFLAGS

disable tests for musl targets, tests use obsolete posix APIs e.g. getcontext

patchout x86_local_resume() on x86, gets a working linunwind on x86, it seems that it wont work even in glibc case but lets leave it as it is for glibc and apply the patch only for musl

---
 .../libunwind-1.1/0001-disable-tests.patch         | 31 +++++++++++++
 .../0001-x86-Stub-out-x86_local_resume.patch       | 54 ++++++++++++++++++++++
 meta/recipes-support/libunwind/libunwind.inc       |  2 +
 meta/recipes-support/libunwind/libunwind_1.1.bb    | 21 +++++----
 4 files changed, 99 insertions(+), 9 deletions(-)
 create mode 100644 meta/recipes-support/libunwind/libunwind-1.1/0001-disable-tests.patch
 create mode 100644 meta/recipes-support/libunwind/libunwind-1.1/0001-x86-Stub-out-x86_local_resume.patch
meta/recipes-support/libunwind/libunwind-1.1/0001-disable-tests.patch new file +31 -0
new file mode 100644
index 0000000..7309ffd
@@ -0,0 +1,31 @@
+From b07435a90bd636ee718e2238fb46c74a6dd5e069 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Tue, 22 Mar 2016 16:41:13 +0000
+Subject: [PATCH] disable tests
+
+Tests use getcontext() API which is
+not there on musl
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+Upstream-Status: Inappropriate [MUSL-only]
+
+ Makefile.am | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index e24fe1e..15380e4 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -39,7 +39,7 @@ endif
+ 
+ nodist_include_HEADERS = include/libunwind-common.h
+ 
+-SUBDIRS = src tests doc
++SUBDIRS = src doc
+ 
+ noinst_HEADERS = include/dwarf.h include/dwarf_i.h include/dwarf-eh.h	\
+ 	include/compiler.h include/libunwind_i.h include/mempool.h	\
+-- 
+1.8.3.1
+
meta/recipes-support/libunwind/libunwind-1.1/0001-x86-Stub-out-x86_local_resume.patch new file +54 -0

54 lines not on this page · raw message

meta/recipes-support/libunwind/libunwind.inc +2 -0
index f83614b..848a50a 100644
@@ -29,4 +29,6 @@ LDFLAGS_append_aarch64 = " -fuse-ld=gold"
 LDFLAGS_append_powerpc = " -fuse-ld=gold -mbss-plt"
 LDFLAGS_append_powerpc64 = " -fuse-ld=gold -mbss-plt"
 
+SECURITY_LDFLAGS_append_libc-musl = " -lssp_nonshared -lssp"
+
 BBCLASSEXTEND = "native"
meta/recipes-support/libunwind/libunwind_1.1.bb +12 -9
index 7df9f5e..1ed525f 100644
@@ -1,15 +1,18 @@
 require libunwind.inc
 
-SRC_URI += "\
-    file://Support-building-with-older-compilers.patch \
-    file://AArch64-port.patch \
-    file://Fix-test-case-link-failure-on-PowerPC-systems-with-Altivec.patch \
-    file://Link-libunwind-to-libgcc_s-rather-than-libgcc.patch \
-    file://0001-Invalid-dwarf-opcodes-can-cause-references-beyond-th.patch \
-    file://Add-AO_REQUIRE_CAS-to-fix-build-on-ARM-v6.patch \
-    file://0001-backtrace-Use-only-with-glibc-and-uclibc.patch \
+SRC_URI = "${SAVANNAH_NONGNU_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \
+           file://Support-building-with-older-compilers.patch \
+           file://AArch64-port.patch \
+           file://Fix-test-case-link-failure-on-PowerPC-systems-with-Altivec.patch \
+           file://Link-libunwind-to-libgcc_s-rather-than-libgcc.patch \
+           file://0001-Invalid-dwarf-opcodes-can-cause-references-beyond-th.patch \
+           file://Add-AO_REQUIRE_CAS-to-fix-build-on-ARM-v6.patch \
+           file://0001-backtrace-Use-only-with-glibc-and-uclibc.patch \
+"
+SRC_URI_append_libc-musl = "\
+           file://0001-x86-Stub-out-x86_local_resume.patch \
+           file://0001-disable-tests.patch \
 "
-
 SRC_URI[md5sum] = "fb4ea2f6fbbe45bf032cd36e586883ce"
 SRC_URI[sha256sum] = "9dfe0fcae2a866de9d3942c66995e4b460230446887dbdab302d41a8aee8d09a"
 
Signature · 1 line
1.8.3.1
#1 lore raw

meta/recipes-support/libunwind/libunwind_1.1.bb line 3

Quoted 12 lines · Khem Raj
meta/recipes-support/libunwind/libunwind_1.1.bb +0 -4
-SRC_URI += "\
-    file://Support-building-with-older-compilers.patch \
-    file://AArch64-port.patch \
-

file://Fix-test-case-link-failure-on-PowerPC-systems-with-Altivec.patch \

meta/recipes-support/libunwind/libunwind_1.1.bb +0 -2
-    file://Link-libunwind-to-libgcc_s-rather-than-libgcc.patch \
-

file://0001-Invalid-dwarf-opcodes-can-cause-references-beyond-th.patch \

meta/recipes-support/libunwind/libunwind_1.1.bb +1 -2
-    file://Add-AO_REQUIRE_CAS-to-fix-build-on-ARM-v6.patch \
-    file://0001-backtrace-Use-only-with-glibc-and-uclibc.patch \
+SRC_URI = "${SAVANNAH_NONGNU_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \

Why change the recipe to use = when the .inc sets the main tarball already?

Ross

author
#2 lore raw
Quoted 15 lines · Ross

On 22 March 2016 at 16:46, Khem Raj <[email protected] <mailto:[email protected]>> wrote:

meta/recipes-support/libunwind/libunwind_1.1.bb +1 -8
-SRC_URI += "\
-    file://Support-building-with-older-compilers.patch \
-    file://AArch64-port.patch \
-    file://Fix-test-case-link-failure-on-PowerPC-systems-with-Altivec.patch \
-    file://Link-libunwind-to-libgcc_s-rather-than-libgcc.patch \
-    file://0001-Invalid-dwarf-opcodes-can-cause-references-beyond-th.patch \
-    file://Add-AO_REQUIRE_CAS-to-fix-build-on-ARM-v6.patch \
-    file://0001-backtrace-Use-only-with-glibc-and-uclibc.patch \
+SRC_URI = "${SAVANNAH_NONGNU_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \
Quoted 2 lines

Why change the recipe to use = when the .inc sets the main tarball already?

I guess I trusted devtool update-recipe too much. will send a v2 soon

Quoted 1 line

Ross