-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows some parts of the code that previously didn't build on musl to build. Additionally, it fixes build on musl ppc setups.
- Loading branch information
Showing
3 changed files
with
108 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
This relies on link.h, which is present in musl as well as glibc. | ||
|
||
--- src/base/elf_mem_image.h | ||
+++ src/base/elf_mem_image.h | ||
@@ -43,7 +43,7 @@ | ||
|
||
// Maybe one day we can rewrite this file not to require the elf | ||
// symbol extensions in glibc, but for right now we need them. | ||
-#if defined(__ELF__) && defined(__GLIBC__) && !defined(__native_client__) | ||
+#if defined(__ELF__) && !defined(__native_client__) | ||
|
||
#define HAVE_ELF_MEM_IMAGE 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
Compatibility fixes for musl. | ||
|
||
--- m4/pc_from_ucontext.m4 | ||
+++ m4/pc_from_ucontext.m4 | ||
@@ -31,6 +31,7 @@ AC_DEFUN([AC_PC_FROM_UCONTEXT], | ||
pc_fields="$pc_fields uc_mcontext.gregs[[R15]]" # Linux (arm old [untested]) | ||
pc_fields="$pc_fields uc_mcontext.arm_pc" # Linux (arm arch 5) | ||
pc_fields="$pc_fields uc_mcontext.gp_regs[[PT_NIP]]" # Suse SLES 11 (ppc64) | ||
+ pc_fields="$pc_fields uc_mcontext.gregs[[PT_NIP]]" | ||
pc_fields="$pc_fields uc_mcontext.mc_eip" # FreeBSD (i386) | ||
pc_fields="$pc_fields uc_mcontext.mc_rip" # FreeBSD (x86_64 [untested]) | ||
pc_fields="$pc_fields uc_mcontext.__gregs[[_REG_EIP]]" # NetBSD (i386) | ||
@@ -55,7 +56,8 @@ AC_DEFUN([AC_PC_FROM_UCONTEXT], | ||
pc_field_found=true) | ||
elif test "x$ac_cv_header_sys_ucontext_h" = xyes; then | ||
AC_TRY_COMPILE([#define _GNU_SOURCE 1 | ||
- #include <sys/ucontext.h>], | ||
+ #include <sys/ucontext.h> | ||
+ #include <asm/ptrace.h>], | ||
[ucontext_t u; return u.$pc_field == 0;], | ||
AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field, | ||
How to access the PC from a struct ucontext) | ||
@@ -63,7 +65,8 @@ AC_DEFUN([AC_PC_FROM_UCONTEXT], | ||
pc_field_found=true) | ||
elif test "x$ac_cv_header_ucontext_h" = xyes; then | ||
AC_TRY_COMPILE([#define _GNU_SOURCE 1 | ||
- #include <ucontext.h>], | ||
+ #include <ucontext.h> | ||
+ #include <asm/ptrace.h>], | ||
[ucontext_t u; return u.$pc_field == 0;], | ||
AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field, | ||
How to access the PC from a struct ucontext) | ||
--- src/getpc.h | ||
+++ src/getpc.h | ||
@@ -65,6 +65,9 @@ | ||
typedef ucontext ucontext_t; | ||
#endif | ||
|
||
+#if defined(__powerpc__) && !defined(PT_NIP) | ||
+#define PT_NIP 32 | ||
+#endif | ||
|
||
// Take the example where function Foo() calls function Bar(). For | ||
// many architectures, Bar() is responsible for setting up and tearing | ||
--- src/stacktrace_powerpc-linux-inl.h | ||
+++ src/stacktrace_powerpc-linux-inl.h | ||
@@ -186,7 +186,7 @@ static int GET_STACK_TRACE_OR_FRAMES { | ||
ucontext_t uc; | ||
// We don't care about the rest, since the IP value is at 'uc' field. | ||
} *sigframe = reinterpret_cast<signal_frame_64*>(current); | ||
- result[n] = (void*) sigframe->uc.uc_mcontext.gp_regs[PT_NIP]; | ||
+ result[n] = (void*) sigframe->uc.uc_mcontext.gp_regs[32]; | ||
} | ||
#else | ||
if (sigtramp32_vdso && (sigtramp32_vdso == current->return_addr)) { | ||
@@ -196,7 +196,7 @@ static int GET_STACK_TRACE_OR_FRAMES { | ||
mcontext_t mctx; | ||
// We don't care about the rest, since IP value is at 'mctx' field. | ||
} *sigframe = reinterpret_cast<signal_frame_32*>(current); | ||
- result[n] = (void*) sigframe->mctx.gregs[PT_NIP]; | ||
+ result[n] = (void*) sigframe->mctx.gregs[32]; | ||
} else if (sigtramp32_rt_vdso && (sigtramp32_rt_vdso == current->return_addr)) { | ||
struct rt_signal_frame_32 { | ||
char dummy[64 + 16]; | ||
@@ -204,7 +204,11 @@ static int GET_STACK_TRACE_OR_FRAMES { | ||
ucontext_t uc; | ||
// We don't care about the rest, since IP value is at 'uc' field.A | ||
} *sigframe = reinterpret_cast<rt_signal_frame_32*>(current); | ||
+#if defined(__GLIBC__) | ||
result[n] = (void*) sigframe->uc.uc_mcontext.uc_regs->gregs[PT_NIP]; | ||
+#else | ||
+ result[n] = (void*) sigframe->uc.uc_mcontext.gregs[32]; | ||
+#endif | ||
} | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters