From dccd5a18cba718e61d618a92cde1fa7e607ad0cf Mon Sep 17 00:00:00 2001 From: Steve Beattie Date: Tue, 14 Jul 2015 10:58:05 -0700 Subject: [PATCH] regression tests: more ptrace adjustments for arm64 upstream changes Merge from trunk commit 3201 In the commit "Rev 3169: regression tests: have ptrace use PTRACE_GETREGSET by default", I created some ifdef magic to use the per arch general purpose register data structures for various architectures, including arm64. Unfortunately, in the upstream glibc commit http://repo.or.cz/w/glibc.git/commitdiff/7d05a8168b45c0580e1f9a79c2dd26c8f0d31fca is no longer included in the arm64 specific user.h, which defined the structure as 'struct user_pt_regs'; instead user.h was converted to define 'struct user_regs_struct'. Because of this, the ptrace test fails to compile on arm64 when glibc is 2.20 or newer. This patch adjusts the ptrace test to use the newer structure on arm64 if it's detected that a newer glibc is detected and reverts to using the older one for older glibcs. It also adds an error when compiling on architectures that haven't been incorporated yet. Signed-off-by: Steve Beattie Acked-by: John Johansen --- tests/regression/apparmor/ptrace.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/regression/apparmor/ptrace.c b/tests/regression/apparmor/ptrace.c index 797ff2f2f..77c7071f2 100644 --- a/tests/regression/apparmor/ptrace.c +++ b/tests/regression/apparmor/ptrace.c @@ -40,9 +40,15 @@ int interp_status(int status) # if defined(__x86_64__) || defined(__i386__) # define ARCH_REGS_STRUCT struct user_regs_struct # elif defined(__aarch64__) -# define ARCH_REGS_STRUCT struct user_pt_regs +# if (__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 20)) +# define ARCH_REGS_STRUCT struct user_regs_struct +# else +# define ARCH_REGS_STRUCT struct user_pt_regs +# endif # elif defined(__arm__) || defined(__powerpc__) || defined(__powerpc64__) # define ARCH_REGS_STRUCT struct pt_regs +# else +# error "Need to define ARCH_REGS_STRUCT for this architecture" # endif int read_ptrace_registers(pid_t pid)