libunwind: refresh patches

0001-src-Gtrace-remove-unguarded-print-calls.patch has been merged, so
update the Upstream-Status.

0003-x86-Stub-out-x86_local_resume.patch has been hopefully obsoleted by
the use of libucontext, remove.

Split 004-Fix-build-on-mips-musl.patch into two, as there's two
independent issues here.

0006-Fix-for-X32.patch appears to have been fixed with 31738a upstream,
in 1.6.0.

musl-header-conflict.patch was obsoleted by recipe-specific-sysroots,
remove it.

(From OE-Core rev: 916c67e3e16c5c355ce6f2a88f3f2a7506af4980)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ross Burton
2024-01-17 15:07:19 +00:00
committed by Richard Purdie
parent e85f0c247f
commit cb02c049f4
8 changed files with 139 additions and 218 deletions

View File

@@ -1,4 +1,4 @@
From 87d24ee47fd0e0461fca32d17564f21d76cbcb92 Mon Sep 17 00:00:00 2001
From 9b27fa9bcd5cadd4c841c42710f41a090377e531 Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@arm.com>
Date: Fri, 24 Mar 2023 16:18:44 +0000
Subject: [PATCH] src/Gtrace: remove unguarded print() calls
@@ -19,7 +19,7 @@ needs to be implemented.
Fixes #482.
Upstream-Status: Submitted [https://github.com/libunwind/libunwind/pull/483]
Upstream-Status: Backport [9b27fa9bcd5cadd4c841c42710f41a090377e531]
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
src/arm/Gtrace.c | 4 ++--

View File

@@ -1,55 +0,0 @@
From 0b2243f19d4ea12a2a68478a5aed503947a800af Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 22 Mar 2016 16:19:29 +0000
Subject: [PATCH] x86: Stub out x86_local_resume()
its purpose seems
to be unwinding across signal handler boundaries, which cannot happen
in correct programs anyway. Replacing the whole function with
something like *(volatile char *)0=0; (i.e. crash), gets a working
libunwind
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/x86/Gos-linux.c | 26 +-------------------------
1 file changed, 1 insertion(+), 25 deletions(-)
diff --git a/src/x86/Gos-linux.c b/src/x86/Gos-linux.c
index d448dce..c25ae0c 100644
--- a/src/x86/Gos-linux.c
+++ b/src/x86/Gos-linux.c
@@ -284,31 +284,7 @@ x86_r_uc_addr (ucontext_t *uc, int reg)
HIDDEN int
x86_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg)
{
- struct cursor *c = (struct cursor *) cursor;
- ucontext_t *uc = c->uc;
-
- /* Ensure c->pi is up-to-date. On x86, it's relatively common to be
- missing DWARF unwind info. We don't want to fail in that case,
- because the frame-chain still would let us do a backtrace at
- least. */
- dwarf_make_proc_info (&c->dwarf);
-
- if (unlikely (c->sigcontext_format != X86_SCF_NONE))
- {
- struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr;
-
- Debug (8, "resuming at ip=%x via sigreturn(%p)\n", c->dwarf.ip, sc);
-#if !defined(__ANDROID__)
- x86_sigreturn (sc);
-#endif
- }
- else
- {
- Debug (8, "resuming at ip=%x via setcontext()\n", c->dwarf.ip);
-#if !defined(__ANDROID__)
- setcontext (uc);
-#endif
- }
+ *(volatile char *)0=0;
return -UNW_EINVAL;
}

View File

@@ -1,84 +0,0 @@
From 6bdab5cc8f1e2ec5f84fc9f59f1699a726980709 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 23 Mar 2016 06:08:59 +0000
Subject: [PATCH 4/6] Fix build on mips/musl
Do not include endian.h on musl it includes
further headers which can not be compiled in __ASSEMBLER__
mode
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/coredump/_UCD_internal.h | 35 +++++++++++++++++++++++++++++++++++
src/mips/getcontext.S | 3 +--
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/coredump/_UCD_internal.h b/src/coredump/_UCD_internal.h
index 3c95a2a..21ed1c3 100644
--- a/src/coredump/_UCD_internal.h
+++ b/src/coredump/_UCD_internal.h
@@ -44,6 +44,41 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "libunwind_i.h"
+#ifndef __GLIBC__
+#include <sys/reg.h>
+
+#define EF_REG0 6
+#define EF_REG1 7
+#define EF_REG2 8
+#define EF_REG3 9
+#define EF_REG4 10
+#define EF_REG5 11
+#define EF_REG6 12
+#define EF_REG7 13
+#define EF_REG8 14
+#define EF_REG9 15
+#define EF_REG10 16
+#define EF_REG11 17
+#define EF_REG12 18
+#define EF_REG13 19
+#define EF_REG14 20
+#define EF_REG15 21
+#define EF_REG16 22
+#define EF_REG17 23
+#define EF_REG18 24
+#define EF_REG19 25
+#define EF_REG20 26
+#define EF_REG21 27
+#define EF_REG22 28
+#define EF_REG23 29
+#define EF_REG24 30
+#define EF_REG25 31
+#define EF_REG28 34
+#define EF_REG29 35
+#define EF_REG30 36
+#define EF_REG31 37
+#endif
+
#if SIZEOF_OFF_T == 4
typedef uint32_t uoff_t;
diff --git a/src/mips/getcontext.S b/src/mips/getcontext.S
index d1dbd57..de9b681 100644
--- a/src/mips/getcontext.S
+++ b/src/mips/getcontext.S
@@ -24,12 +24,11 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "offsets.h"
-#include <endian.h>
.text
#if _MIPS_SIM == _ABIO32
-# if __BYTE_ORDER == __BIG_ENDIAN
+# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define OFFSET 4
# else
# define OFFSET 0
--
2.20.1

View File

@@ -1,29 +0,0 @@
From f2eae0af620925b3686410470fc6fbc66ec1dc52 Mon Sep 17 00:00:00 2001
From: Christopher Larson <chris_larson@mentor.com>
Date: Tue, 13 Dec 2016 09:50:34 -0700
Subject: [PATCH] Fix for X32
Apply patch to fix the X32 build from https://github.com/sjnewbury/x32.
Upstream-Status: Pending
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
src/x86_64/Gos-linux.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/x86_64/Gos-linux.c b/src/x86_64/Gos-linux.c
index b489329..0550005 100644
--- a/src/x86_64/Gos-linux.c
+++ b/src/x86_64/Gos-linux.c
@@ -146,8 +146,8 @@ x86_64_sigreturn (unw_cursor_t *cursor)
Debug (8, "resuming at ip=%llx via sigreturn(%p)\n",
(unsigned long long) c->dwarf.ip, sc);
- __asm__ __volatile__ ("mov %0, %%rsp;"
- "mov %1, %%rax;"
+ __asm__ __volatile__ ("mov %q0, %%rsp;"
+ "mov %q1, %%rax;"
"syscall"
:: "r"((uint64_t)sc), "i"(SYS_rt_sigreturn)
: "memory");

View File

@@ -0,0 +1,35 @@
From dbbf8110ed3fd2cbac20a8ec2ac769e13c67bab1 Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@arm.com>
Date: Tue, 16 Jan 2024 18:22:38 +0000
Subject: [PATCH 2/2] byte order
endian.h on musl/mips can't be included in __ASSEMBLER__ mode,
so use the __BYTE_ORDER__ symbol instead.
Upstream-Status: Pending
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
src/mips/getcontext.S | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/mips/getcontext.S b/src/mips/getcontext.S
index d1dbd579..de9b6818 100644
--- a/src/mips/getcontext.S
+++ b/src/mips/getcontext.S
@@ -24,12 +24,11 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "offsets.h"
-#include <endian.h>
.text
#if _MIPS_SIM == _ABIO32
-# if __BYTE_ORDER == __BIG_ENDIAN
+# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define OFFSET 4
# else
# define OFFSET 0
--
2.34.1

View File

@@ -0,0 +1,100 @@
From 7750e2a29b084ee033acc82abab410035e220d3f Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@arm.com>
Date: Tue, 16 Jan 2024 18:21:26 +0000
Subject: [PATCH 1/2] coredump-mips-register
glibc and musl have different names for the registers, add a
macro that generates the names appropriately.
Upstream-Status: Pending
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
src/coredump/_UCD_access_reg_linux.c | 69 ++++++++++++++++------------
1 file changed, 39 insertions(+), 30 deletions(-)
diff --git a/src/coredump/_UCD_access_reg_linux.c b/src/coredump/_UCD_access_reg_linux.c
index 27eef123..beefdb47 100644
--- a/src/coredump/_UCD_access_reg_linux.c
+++ b/src/coredump/_UCD_access_reg_linux.c
@@ -67,38 +67,47 @@ _UCD_access_reg (unw_addr_space_t as,
goto badreg;
#else
#if defined(UNW_TARGET_MIPS)
+
+/* glibc and musl use different names */
+#ifdef __GLIBC__
+#define EF_REG(x) EF_REG ## x
+#else
+#include <sys/reg.h>
+#define EF_REG(x) EF_R ## x
+#endif
+
static const uint8_t remap_regs[] =
{
- [UNW_MIPS_R0] = EF_REG0,
- [UNW_MIPS_R1] = EF_REG1,
- [UNW_MIPS_R2] = EF_REG2,
- [UNW_MIPS_R3] = EF_REG3,
- [UNW_MIPS_R4] = EF_REG4,
- [UNW_MIPS_R5] = EF_REG5,
- [UNW_MIPS_R6] = EF_REG6,
- [UNW_MIPS_R7] = EF_REG7,
- [UNW_MIPS_R8] = EF_REG8,
- [UNW_MIPS_R9] = EF_REG9,
- [UNW_MIPS_R10] = EF_REG10,
- [UNW_MIPS_R11] = EF_REG11,
- [UNW_MIPS_R12] = EF_REG12,
- [UNW_MIPS_R13] = EF_REG13,
- [UNW_MIPS_R14] = EF_REG14,
- [UNW_MIPS_R15] = EF_REG15,
- [UNW_MIPS_R16] = EF_REG16,
- [UNW_MIPS_R17] = EF_REG17,
- [UNW_MIPS_R18] = EF_REG18,
- [UNW_MIPS_R19] = EF_REG19,
- [UNW_MIPS_R20] = EF_REG20,
- [UNW_MIPS_R21] = EF_REG21,
- [UNW_MIPS_R22] = EF_REG22,
- [UNW_MIPS_R23] = EF_REG23,
- [UNW_MIPS_R24] = EF_REG24,
- [UNW_MIPS_R25] = EF_REG25,
- [UNW_MIPS_R28] = EF_REG28,
- [UNW_MIPS_R29] = EF_REG29,
- [UNW_MIPS_R30] = EF_REG30,
- [UNW_MIPS_R31] = EF_REG31,
+ [UNW_MIPS_R0] = EF_REG(0),
+ [UNW_MIPS_R1] = EF_REG(1),
+ [UNW_MIPS_R2] = EF_REG(2),
+ [UNW_MIPS_R3] = EF_REG(3),
+ [UNW_MIPS_R4] = EF_REG(4),
+ [UNW_MIPS_R5] = EF_REG(5),
+ [UNW_MIPS_R6] = EF_REG(6),
+ [UNW_MIPS_R7] = EF_REG(7),
+ [UNW_MIPS_R8] = EF_REG(8),
+ [UNW_MIPS_R9] = EF_REG(9),
+ [UNW_MIPS_R10] = EF_REG(10),
+ [UNW_MIPS_R11] = EF_REG(11),
+ [UNW_MIPS_R12] = EF_REG(12),
+ [UNW_MIPS_R13] = EF_REG(13),
+ [UNW_MIPS_R14] = EF_REG(14),
+ [UNW_MIPS_R15] = EF_REG(15),
+ [UNW_MIPS_R16] = EF_REG(16),
+ [UNW_MIPS_R17] = EF_REG(17),
+ [UNW_MIPS_R18] = EF_REG(18),
+ [UNW_MIPS_R19] = EF_REG(19),
+ [UNW_MIPS_R20] = EF_REG(20),
+ [UNW_MIPS_R21] = EF_REG(21),
+ [UNW_MIPS_R22] = EF_REG(22),
+ [UNW_MIPS_R23] = EF_REG(23),
+ [UNW_MIPS_R24] = EF_REG(24),
+ [UNW_MIPS_R25] = EF_REG(25),
+ [UNW_MIPS_R28] = EF_REG(28),
+ [UNW_MIPS_R29] = EF_REG(29),
+ [UNW_MIPS_R30] = EF_REG(30),
+ [UNW_MIPS_R31] = EF_REG(31),
[UNW_MIPS_PC] = EF_CP0_EPC,
};
#elif defined(UNW_TARGET_X86)
--
2.34.1

View File

@@ -1,44 +0,0 @@
From e1de5a5b42062dc02769f320c7785928b2ee0c57 Mon Sep 17 00:00:00 2001
From: Richard Purdie <richard.purdie@linuxfoundation.org>
Date: Thu, 18 Aug 2016 14:46:32 +0100
Subject: [PATCH] If you:
TCLIBC=musl bitbake unwind
TCLIBC=musl bitbake gcc-runtime -c cleansstate
TCLIBC=musl bitbake gcc-runtime
you will see libstdc++ fail to build due to finding libunwind's header file.
Khem: "When we build any of gcc components they expect to use internal version
and that works with glibc based gcc since the search headers first look into gcc
headers, however with musl the gcc headers are searched after the standard
headers ( which is by design the right thing )."
This patch hacks around the issue by looking for a define used during gcc-runtime's
build and skipping to the internal header in that case.
[YOCTO #10129]
RP 2016/8/18
Upstream-Status: Inappropriate [really need to fix gcc]
---
include/unwind.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/unwind.h b/include/unwind.h
index 93780fa..c812414 100644
--- a/include/unwind.h
+++ b/include/unwind.h
@@ -23,6 +23,10 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+#ifdef _GLIBCXX_SHARED
+#include_next <unwind.h>
+#endif
+
#ifndef _UNWIND_H
#define _UNWIND_H

View File

@@ -7,13 +7,11 @@ DEPENDS += "libatomic-ops"
DEPENDS:append:libc-musl = " libucontext"
SRC_URI = "http://download.savannah.nongnu.org/releases/libunwind/libunwind-${PV}.tar.gz \
file://0003-x86-Stub-out-x86_local_resume.patch \
file://0004-Fix-build-on-mips-musl.patch \
file://mips-byte-order.patch \
file://mips-coredump-register.patch \
file://0005-ppc32-Consider-ucontext-mismatches-between-glibc-and.patch \
file://0006-Fix-for-X32.patch \
file://0001-src-Gtrace-remove-unguarded-print-calls.patch \
"
SRC_URI:append:libc-musl = " file://musl-header-conflict.patch"
SRC_URI[sha256sum] = "4a6aec666991fb45d0889c44aede8ad6eb108071c3554fcdff671f9c94794976"