| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * unwind_vdso.c - tests unwind info for AT_SYSINFO in the vDSO |
|---|
| 3 | 4 | * Copyright (c) 2014-2015 Andrew Lutomirski |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | | - * it under the terms and conditions of the GNU General Public License, |
|---|
| 7 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope it will be useful, but |
|---|
| 10 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 12 | | - * General Public License for more details. |
|---|
| 13 | 5 | * |
|---|
| 14 | 6 | * This tests __kernel_vsyscall's unwind info. |
|---|
| 15 | 7 | */ |
|---|
| .. | .. |
|---|
| 18 | 10 | |
|---|
| 19 | 11 | #include <features.h> |
|---|
| 20 | 12 | #include <stdio.h> |
|---|
| 13 | + |
|---|
| 14 | +#include "helpers.h" |
|---|
| 21 | 15 | |
|---|
| 22 | 16 | #if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 16 |
|---|
| 23 | 17 | |
|---|
| .. | .. |
|---|
| 44 | 38 | #include <stdbool.h> |
|---|
| 45 | 39 | #include <sys/ptrace.h> |
|---|
| 46 | 40 | #include <sys/user.h> |
|---|
| 47 | | -#include <sys/ucontext.h> |
|---|
| 48 | 41 | #include <link.h> |
|---|
| 49 | 42 | #include <sys/auxv.h> |
|---|
| 50 | 43 | #include <dlfcn.h> |
|---|
| .. | .. |
|---|
| 61 | 54 | if (sigaction(sig, &sa, 0)) |
|---|
| 62 | 55 | err(1, "sigaction"); |
|---|
| 63 | 56 | } |
|---|
| 64 | | - |
|---|
| 65 | | -#ifdef __x86_64__ |
|---|
| 66 | | -# define WIDTH "q" |
|---|
| 67 | | -#else |
|---|
| 68 | | -# define WIDTH "l" |
|---|
| 69 | | -#endif |
|---|
| 70 | | - |
|---|
| 71 | | -static unsigned long get_eflags(void) |
|---|
| 72 | | -{ |
|---|
| 73 | | - unsigned long eflags; |
|---|
| 74 | | - asm volatile ("pushf" WIDTH "\n\tpop" WIDTH " %0" : "=rm" (eflags)); |
|---|
| 75 | | - return eflags; |
|---|
| 76 | | -} |
|---|
| 77 | | - |
|---|
| 78 | | -static void set_eflags(unsigned long eflags) |
|---|
| 79 | | -{ |
|---|
| 80 | | - asm volatile ("push" WIDTH " %0\n\tpopf" WIDTH |
|---|
| 81 | | - : : "rm" (eflags) : "flags"); |
|---|
| 82 | | -} |
|---|
| 83 | | - |
|---|
| 84 | | -#define X86_EFLAGS_TF (1UL << 8) |
|---|
| 85 | 57 | |
|---|
| 86 | 58 | static volatile sig_atomic_t nerrs; |
|---|
| 87 | 59 | static unsigned long sysinfo; |
|---|