From: Dmitry V. Levin Date: Tue, 9 Jul 2019 19:27:58 +0000 (+0000) Subject: tests: robustify strace -k tests against link-time optimizer X-Git-Tag: v5.2~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e9ff1e84081f89f24e27edc9dcfad12c43e51ec3;p=strace tests: robustify strace -k tests against link-time optimizer Some distributions enable by default a link-time optimizer that mangles stack_fcall sample executables in a way that renders them unusable for test purposes. Robustify tests to defeat link-time optimizer. * tests/stack-fcall.h (f0, f1, f2, f3): Add second parameter. * tests/stack-fcall.c (main): Pass main as the second parameter to f0. * tests/stack-fcall-0.c (f0): Add second parameter f, pass the xor of it and f0 to f1. * tests/stack-fcall-1.c (f1): Add second parameter f, pass the xor of it and f1 to f2. * tests/stack-fcall-2.c (f2): Add second parameter f, pass the xor of it and f2 to f3. * tests/stack-fcall-3.c: Include . (f3): Add second parameter f, invoke __NR_gettid syscall with the xor of f and f3 as its argument. --- diff --git a/tests/stack-fcall-0.c b/tests/stack-fcall-0.c index 8a26a79c..e334df1c 100644 --- a/tests/stack-fcall-0.c +++ b/tests/stack-fcall-0.c @@ -7,7 +7,7 @@ #include "stack-fcall.h" -int f0(int i) +int f0(int i, unsigned long f) { - return f1(i) - i; + return f1(i, f ^ (unsigned long) (void *) f0) - i; } diff --git a/tests/stack-fcall-1.c b/tests/stack-fcall-1.c index b5cd89b3..96888ef0 100644 --- a/tests/stack-fcall-1.c +++ b/tests/stack-fcall-1.c @@ -7,7 +7,7 @@ #include "stack-fcall.h" -int f1(int i) +int f1(int i, unsigned long f) { - return f2(i) + i; + return f2(i, f ^ (unsigned long) (void *) f1) + i; } diff --git a/tests/stack-fcall-2.c b/tests/stack-fcall-2.c index 16beee58..9386f4ab 100644 --- a/tests/stack-fcall-2.c +++ b/tests/stack-fcall-2.c @@ -7,7 +7,7 @@ #include "stack-fcall.h" -int f2(int i) +int f2(int i, unsigned long f) { - return f3(i) - i; + return f3(i, f ^ (unsigned long) (void *) f2) - i; } diff --git a/tests/stack-fcall-3.c b/tests/stack-fcall-3.c index 538b6565..d027e326 100644 --- a/tests/stack-fcall-3.c +++ b/tests/stack-fcall-3.c @@ -7,11 +7,13 @@ #include #include +#include #include "stack-fcall.h" -int f3(int i) +int f3(int i, unsigned long f) { + syscall(__NR_gettid, f ^ (unsigned long) (void *) f3); switch (i) { case 1: return kill(getpid(), SIGURG); diff --git a/tests/stack-fcall.c b/tests/stack-fcall.c index cf4000e5..bc970b24 100644 --- a/tests/stack-fcall.c +++ b/tests/stack-fcall.c @@ -9,7 +9,7 @@ int main(void) { - f0(0); - f0(1); + f0(0, (unsigned long) (void *) main); + f0(1, (unsigned long) (void *) main); return 0; } diff --git a/tests/stack-fcall.h b/tests/stack-fcall.h index cca0f94f..881fca28 100644 --- a/tests/stack-fcall.h +++ b/tests/stack-fcall.h @@ -14,7 +14,7 @@ #endif -int f0(int i); -int f1(int i); -int f2(int i); -int f3(int i); +int f0(int i, unsigned long); +int f1(int i, unsigned long); +int f2(int i, unsigned long); +int f3(int i, unsigned long);