summaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-11-24 08:35:09 +0000
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-11-24 08:35:09 +0000
commitf827eb8f60d926607ee409dbbc93159a1e52c4d6 (patch)
tree35d4bf7d020cc83f0fcdd6826431dca6dfbc425b /system
parent92fb930d4fcbdd4ec0996210c9323ce38d567efd (diff)
downloadpackages-f827eb8f60d926607ee409dbbc93159a1e52c4d6.tar.gz
packages-f827eb8f60d926607ee409dbbc93159a1e52c4d6.tar.bz2
packages-f827eb8f60d926607ee409dbbc93159a1e52c4d6.tar.xz
packages-f827eb8f60d926607ee409dbbc93159a1e52c4d6.zip
system/musl: add ability to add default stack size to binaries
Diffstat (limited to 'system')
-rw-r--r--system/musl/APKBUILD6
-rw-r--r--system/musl/dynamic-binary-stack-size.patch97
2 files changed, 101 insertions, 2 deletions
diff --git a/system/musl/APKBUILD b/system/musl/APKBUILD
index 08f4342dd..dbbfe640c 100644
--- a/system/musl/APKBUILD
+++ b/system/musl/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: A. Wilcox <awilfox@adelielinux.org>
pkgname=musl
pkgver=1.1.20
-pkgrel=4
+pkgrel=5
pkgdesc="System library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
@@ -11,7 +11,7 @@ license="MIT"
depends=""
depends_dev="!uclibc-dev"
makedepends="$depends_dev"
-subpackages="$pkgname-dev $pkgname-dbg"
+subpackages="$pkgname-dev"
case "$BOOTSTRAP" in
nocc) pkgname="musl-dev"
subpackages=""
@@ -32,6 +32,7 @@ source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz
dcngettext-null-deref.patch
getaddrinfo-regression.patch
ppc64-atomic.patch
+ dynamic-binary-stack-size.patch
ldconfig
getent.c
@@ -127,6 +128,7 @@ b967339d9048161583523e847be91779adb0e16cc225d6ff85ef51748269b2dab08a0b8e558ad014
a08d1b170356beea333ace1da12f8a8399ca80c5d9c32ff2fcd8562537a670214f566e4b1219a11b32129078e22fbf7009bb277b7de8550a89352a64b3b5090d dcngettext-null-deref.patch
e3953a3a73ef11696dd3eb216e18b152ae35198d8bff686d157e27bc90fb558f9a0be518025a90534e9afd6ea1bf731ffdb6fcb202bb9368f2c8eec7ca886141 getaddrinfo-regression.patch
aae9110eccb8cd7dcd3c957fcb01ed524598f79f7fa1a16b9993af40793545d1ec211e7e6aeabe7af7715d94cc26a473ea0acf6d6e66019bf65f03d4b8e24a4b ppc64-atomic.patch
+654f76c96ed0e69e19b1a20569e83751bb207a8c181b26742f505638095dde3f4dd3f785deb92c49a603bd15cd8d4932129f567de8cd2edffdd8551c4dfd6976 dynamic-binary-stack-size.patch
cce2f1eeb61e55674469c26871a573cce61d739c3defe9c8f56f2b774f6ba5435849ad542a6714120efddc98c297098e9c98a1a424ac593df2243d4aa479f9a9 ldconfig
378d70e65bcc65bb4e1415354cecfa54b0c1146dfb24474b69e418cdbf7ad730472cd09f6f103e1c99ba6c324c9560bccdf287f5889bbc3ef0bdf0e08da47413 getent.c
9d42d66fb1facce2b85dad919be5be819ee290bd26ca2db00982b2f8e055a0196290a008711cbe2b18ec9eee8d2270e3b3a4692c5a1b807013baa5c2b70a2bbf iconv.c"
diff --git a/system/musl/dynamic-binary-stack-size.patch b/system/musl/dynamic-binary-stack-size.patch
new file mode 100644
index 000000000..e2e3f12d3
--- /dev/null
+++ b/system/musl/dynamic-binary-stack-size.patch
@@ -0,0 +1,97 @@
+From 7b3348a98c139b4b4238384e52d4b0eb237e4833 Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Tue, 18 Sep 2018 23:54:18 -0400
+Subject: support setting of default thread stack size via PT_GNU_STACK header
+
+this facilitates building software that assumes a large default stack
+size without any patching to call pthread_setattr_default_np or
+pthread_attr_setstacksize at each thread creation site, using just
+LDFLAGS.
+
+normally the PT_GNU_STACK header is used only to reflect whether
+executable stack is desired, but with GNU ld at least, passing
+-Wl,-z,stack-size=N will set a size on the program header. with this
+patch, that size will be incorporated into the default stack size
+(subject to increase-only rule and DEFAULT_STACK_MAX limit).
+
+both static and dynamic linking honor the program header. for dynamic
+linking, all libraries loaded at program start, including preloaded
+ones, are considered. dlopened libraries are not considered, for
+several reasons. extra logic would be needed to defer processing until
+the load of the new library is commited, synchronization woud be
+needed since other threads may be running concurrently, and the
+effectiveness woud be limited since the larger size would not apply to
+threads that already existed at the time of dlopen. programs that will
+dlopen code expecting a large stack need to declare the requirement
+themselves, or pthread_setattr_default_np can be used.
+---
+ ldso/dynlink.c | 12 ++++++++++++
+ src/env/__init_tls.c | 5 +++++
+ 2 files changed, 17 insertions(+)
+
+diff --git a/ldso/dynlink.c b/ldso/dynlink.c
+index e4829c3a..3ecbddfa 100644
+--- a/ldso/dynlink.c
++++ b/ldso/dynlink.c
+@@ -22,6 +22,7 @@
+ #include "dynlink.h"
+
+ static void error(const char *, ...);
++extern size_t __default_stacksize;
+
+ #define MAXP2(a,b) (-(-(a)&-(b)))
+ #define ALIGN(x,y) ((x)+(y)-1 & -(y))
+@@ -609,6 +610,12 @@ static void *map_library(int fd, struct dso *dso)
+ } else if (ph->p_type == PT_GNU_RELRO) {
+ dso->relro_start = ph->p_vaddr & -PAGE_SIZE;
+ dso->relro_end = (ph->p_vaddr + ph->p_memsz) & -PAGE_SIZE;
++ } else if (ph->p_type == PT_GNU_STACK) {
++ if (!runtime && ph->p_memsz > __default_stacksize) {
++ __default_stacksize =
++ ph->p_memsz < (8<<20) ?
++ ph->p_memsz : (8<<20);
++ }
+ }
+ if (ph->p_type != PT_LOAD) continue;
+ nsegs++;
+@@ -1238,6 +1245,12 @@ static void kernel_mapped_dso(struct dso *p)
+ } else if (ph->p_type == PT_GNU_RELRO) {
+ p->relro_start = ph->p_vaddr & -PAGE_SIZE;
+ p->relro_end = (ph->p_vaddr + ph->p_memsz) & -PAGE_SIZE;
++ } else if (ph->p_type == PT_GNU_STACK) {
++ if (!runtime && ph->p_memsz > __default_stacksize) {
++ __default_stacksize =
++ ph->p_memsz < (8<<20) ?
++ ph->p_memsz : (8<<20);
++ }
+ }
+ if (ph->p_type != PT_LOAD) continue;
+ if (ph->p_vaddr < min_addr)
+diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c
+index e0224243..96d0e284 100644
+--- a/src/env/__init_tls.c
++++ b/src/env/__init_tls.c
+@@ -8,6 +8,8 @@
+ #include "atomic.h"
+ #include "syscall.h"
+
++extern size_t __default_stacksize;
++
+ int __init_tp(void *p)
+ {
+ pthread_t td = p;
+@@ -90,6 +91,11 @@ static void static_init_tls(size_t *aux)
+ base = (size_t)_DYNAMIC - phdr->p_vaddr;
+ if (phdr->p_type == PT_TLS)
+ tls_phdr = phdr;
++ if (phdr->p_type == PT_GNU_STACK &&
++ phdr->p_memsz > __default_stacksize)
++ __default_stacksize =
++ phdr->p_memsz < (8<<20) ?
++ phdr->p_memsz : (8<<20);
+ }
+
+ if (tls_phdr) {
+--
+cgit v1.2.1
+