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 <ldv@altlinux.org>
Fixes: v4.26~50 "Check whether PTRACE_GET_SYSCALL_INFO is supported by the kernel"
This commit is contained in:
Baruch Siach 2019-01-08 18:36:20 +02:00 committed by Dmitry V. Levin
parent 04512207ac
commit f414d9e3ba
3 changed files with 8 additions and 7 deletions

1
NEWS
View File

@ -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)
===============================================

View File

@ -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;
}

View File

@ -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 -