From f414d9e3bae40e4eb6426a6d414f0ec2265e93ae Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Tue, 8 Jan 2019 18:36:20 +0200 Subject: [PATCH] Fix build for no-MMU targets Commit 7488ce9e23f1 "Check whether PTRACE_GET_SYSCALL_INFO is supported by the kernel" added a fork() call in test_ptrace_get_syscall_info() which is included in the main strace executable code. Although the test_ptrace_get_syscall_info() routine is not called on no-MMU targets, the compiler can't optimize it out because it is a global symbol. So build for no-MMU targets currently fails: strace-ptrace_syscall_info.o: In function `test_ptrace_get_syscall_info': ptrace_syscall_info.c:(.text+0x1c): undefined reference to `fork' * ptrace_syscall_info.c (test_ptrace_get_syscall_info): Make the definition depend on HAVE_FORK. * strace.c (init): Call test_ptrace_get_syscall_info unconditionally. * NEWS: Mention this fix. Co-Authored-by: Dmitry V. Levin Fixes: v4.26~50 "Check whether PTRACE_GET_SYSCALL_INFO is supported by the kernel" --- NEWS | 1 + ptrace_syscall_info.c | 6 ++++++ strace.c | 8 +------- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 151b2cfd..8df5926f 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ Noteworthy changes in release ?.?? (????-??-??) * Bug fixes * Fixed strace-k test on alpha. + * Fixed build on NOMMU architectures. Noteworthy changes in release 4.26 (2018-12-26) =============================================== diff --git a/ptrace_syscall_info.c b/ptrace_syscall_info.c index 55eafddf..7af5eb27 100644 --- a/ptrace_syscall_info.c +++ b/ptrace_syscall_info.c @@ -43,6 +43,11 @@ static const unsigned int expected_seccomp_size = bool test_ptrace_get_syscall_info(void) { + /* + * NOMMU provides no forks necessary for PTRACE_GET_SYSCALL_INFO test, + * leave the default unchanged. + */ +#ifdef HAVE_FORK static const unsigned long args[][7] = { /* a sequence of architecture-agnostic syscalls */ { @@ -252,6 +257,7 @@ done: debug_msg("PTRACE_GET_SYSCALL_INFO works"); else debug_msg("PTRACE_GET_SYSCALL_INFO does not work"); +#endif /* HAVE_FORK */ return ptrace_get_syscall_info_supported; } diff --git a/strace.c b/strace.c index 06e2796a..cdaafa87 100644 --- a/strace.c +++ b/strace.c @@ -1800,13 +1800,7 @@ init(int argc, char *argv[]) PTRACE_O_TRACEVFORK; debug_msg("ptrace_setoptions = %#x", ptrace_setoptions); test_ptrace_seize(); - - /* - * NOMMU provides no forks necessary for PTRACE_GET_SYSCALL_INFO test, - * leave the default unchanged. - */ - if (!NOMMU_SYSTEM) - test_ptrace_get_syscall_info(); + test_ptrace_get_syscall_info(); /* * Is something weird with our stdin and/or stdout - -- 2.40.0