mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-08-06 22:07:19 +02:00
main/libucontext: fix build with -Os on x86
See: * https://github.com/kaniini/libucontext/issues/52#issuecomment-1936736286 * https://github.com/kaniini/libucontext/pull/60
This commit is contained in:
parent
e25755a2fd
commit
687c90dea7
@ -0,0 +1,47 @@
|
|||||||
|
From 13437174df7cd45873cf2d1d9c4c4277e2db8a5a Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
|
||||||
|
Date: Sat, 10 Feb 2024 00:13:28 +0100
|
||||||
|
Subject: [PATCH] common-trampoline: Ensure omission of frame-pointer
|
||||||
|
|
||||||
|
Some architecture-specific implementations of the FETCH_LINKPTR
|
||||||
|
(e.g. the one for x86) attempt to find the linkptr relative to the
|
||||||
|
stack pointer. Therefore, they make assumption about the value of
|
||||||
|
the SP at the point where the FETCH_LINKPTR code is executed. This
|
||||||
|
means that we don't want the C compiler to mess with our SP.
|
||||||
|
|
||||||
|
For this purpose, local variables in this function are currently
|
||||||
|
declared using the register storage specifier. Additionally, we
|
||||||
|
need to make sure that a frame pointer is /always/ omitted for
|
||||||
|
this function. On x86 Alpine, the frame pointer is presently not
|
||||||
|
omitted with GCC 13 when using -Os, therefore the tests segfault
|
||||||
|
with -Os on Alpine presently.
|
||||||
|
|
||||||
|
Fixes #52
|
||||||
|
---
|
||||||
|
arch/common/common-trampoline.c | 12 ++++++++++++
|
||||||
|
1 file changed, 12 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/arch/common/common-trampoline.c b/arch/common/common-trampoline.c
|
||||||
|
index 5b52327..41f994b 100644
|
||||||
|
--- a/arch/common/common-trampoline.c
|
||||||
|
+++ b/arch/common/common-trampoline.c
|
||||||
|
@@ -14,7 +14,19 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
+/* We need to make sure that the C compiler doesn't push any
|
||||||
|
+ * additional data to the stack frame. Otherwise, assumptions
|
||||||
|
+ * made by the architecture-specific implementation of the
|
||||||
|
+ * FETCH_LINKPTR() macro about the location of the linkptr,
|
||||||
|
+ * relative to the stack pointer, will not hold.
|
||||||
|
+ *
|
||||||
|
+ * Hence, we compile this function with -fomit-frame-pointer
|
||||||
|
+ * and use the register storage-class specifier for all local
|
||||||
|
+ * vars. Note that the latter is just a "suggestion" (see C99).
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
__attribute__ ((visibility ("hidden")))
|
||||||
|
+__attribute__ ((optimize ("omit-frame-pointer")))
|
||||||
|
void
|
||||||
|
libucontext_trampoline(void)
|
||||||
|
{
|
@ -1,14 +1,15 @@
|
|||||||
# Maintainer: Ariadne Conill <ariadne@dereferenced.org>
|
# Maintainer: Ariadne Conill <ariadne@dereferenced.org>
|
||||||
pkgname=libucontext
|
pkgname=libucontext
|
||||||
pkgver=1.2
|
pkgver=1.2
|
||||||
pkgrel=2
|
pkgrel=3
|
||||||
pkgdesc="ucontext function implementations"
|
pkgdesc="ucontext function implementations"
|
||||||
url="https://github.com/kaniini/libucontext"
|
url="https://github.com/kaniini/libucontext"
|
||||||
arch="all"
|
arch="all"
|
||||||
license="ISC"
|
license="ISC"
|
||||||
subpackages="$pkgname-dev $pkgname-doc"
|
subpackages="$pkgname-dev $pkgname-doc"
|
||||||
makedepends="scdoc"
|
makedepends="scdoc"
|
||||||
source="https://distfiles.ariadne.space/libucontext/libucontext-$pkgver.tar.xz"
|
source="https://distfiles.ariadne.space/libucontext/libucontext-$pkgver.tar.xz
|
||||||
|
0001-common-trampoline-Ensure-omission-of-frame-pointer.patch"
|
||||||
|
|
||||||
case "$CTARGET_ARCH" in
|
case "$CTARGET_ARCH" in
|
||||||
arm*) LIBUCONTEXT_ARCH="arm" ;;
|
arm*) LIBUCONTEXT_ARCH="arm" ;;
|
||||||
@ -17,10 +18,6 @@ case "$CTARGET_ARCH" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
# workaround segfault on x86 with -Os
|
|
||||||
# https://github.com/kaniini/libucontext/issues/52
|
|
||||||
CFLAGS="$CFLAGS -O2"
|
|
||||||
|
|
||||||
make ARCH="$LIBUCONTEXT_ARCH"
|
make ARCH="$LIBUCONTEXT_ARCH"
|
||||||
make ARCH="$LIBUCONTEXT_ARCH" docs
|
make ARCH="$LIBUCONTEXT_ARCH" docs
|
||||||
}
|
}
|
||||||
@ -35,4 +32,5 @@ package() {
|
|||||||
|
|
||||||
sha512sums="
|
sha512sums="
|
||||||
6603f2dcd87c4d9919c1726f2964632483e1a647733ff543d5935e3e2dac548adf320f1f9fb4c494691fe99fb393d64b15369f04d3783b2ca4c40b68c3d87865 libucontext-1.2.tar.xz
|
6603f2dcd87c4d9919c1726f2964632483e1a647733ff543d5935e3e2dac548adf320f1f9fb4c494691fe99fb393d64b15369f04d3783b2ca4c40b68c3d87865 libucontext-1.2.tar.xz
|
||||||
|
4e797976943dcc98dbc2541a17e517da1b95ed50e0c730c547ccc604e682d1150e90c6bb29f601549b6a0bf4b7228e7a7d9883e97ea6bff4d12956df6b9a1195 0001-common-trampoline-Ensure-omission-of-frame-pointer.patch
|
||||||
"
|
"
|
||||||
|
Loading…
Reference in New Issue
Block a user