When compiling against musl, I found that execinfo.h is used
unconditionally, even though it is a glibc extension, and that
asm/unistd.h is included directly (it does not exist in musl) and not
via sys/syscall.h.

This patch changes these two issues.
---
 src/x86_64/setcontext.S      | 2 +-
 tests/test-coredump-unwind.c | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/x86_64/setcontext.S b/src/x86_64/setcontext.S
index 1af8b67..9510c74 100644
--- a/src/x86_64/setcontext.S
+++ b/src/x86_64/setcontext.S
@@ -26,7 +26,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.  */

 #include "ucontext_i.h"
 #if defined __linux__
-#include <asm/unistd.h>
+#include <sys/syscall.h>
 #define SIG_SETMASK   2
 #define SIGSET_BYTE_SIZE   (64/8)
 #elif defined __FreeBSD__
diff --git a/tests/test-coredump-unwind.c b/tests/test-coredump-unwind.c
index 5254708..0bb4010 100644
--- a/tests/test-coredump-unwind.c
+++ b/tests/test-coredump-unwind.c
@@ -31,6 +31,7 @@
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <features.h>
 #include <inttypes.h>
 #include <setjmp.h>
 #include <signal.h>
@@ -57,7 +58,9 @@
 #include <grp.h>

 /* For SIGSEGV handler code */
+#ifdef __GLIBC__
 #include <execinfo.h>
+#endif
 #include <sys/ucontext.h>

 #include <libunwind-coredump.h>
@@ -242,7 +245,7 @@ void handle_sigsegv(int sig, siginfo_t *info, void
*ucontext)
     void *array[50];
     int size;
     size = backtrace(array, 50);
-#ifdef __linux__
+#if defined(__linux__) && defined(__GLIBC__)
     backtrace_symbols_fd(array, size, 2);
 #endif
   }
-- 
2.4.3
_______________________________________________
Libunwind-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/libunwind-devel

Reply via email to