(root)/
strace-6.5/
tests/
cur_audit_arch.h
       1  /*
       2   * Provides an AUDIT_ARCH_* constant for the current process in CUR_AUDIT_ARCH
       3   * macro for some architectures (where such a constant defined).
       4   *
       5   * Copyright (c) 2021 Eugene Syromyatnikov <evgsyr@gmail.com>
       6   * All rights reserved.
       7   *
       8   * SPDX-License-Identifier: GPL-2.0-or-later
       9   */
      10  
      11  #ifndef STRACE_TESTS_CUR_AUDIT_ARCH_H
      12  # define STRACE_TESTS_CUR_AUDIT_ARCH_H
      13  
      14  # include <linux/audit.h>
      15  
      16  /*
      17   * If only one could easily get AUDIT_ARCH_* of the running process...
      18   * CUR_AUDIT_ARCH - AUDIT_ARCH_* of the current personality
      19   * PERS0_AUDIT_ARCH - AUDIT_ARCH_* of the strace's default personality
      20   *                    if the current one is mpers
      21   * PERS0__NR_gettid - gettid() syscall number in strace's default personality
      22   * M32_AUDIT_ARCH, MX32_AUDIT_ARCH - AUDIT_ARCH_* values for mpers
      23   * M32__NR_gettid, MX32_NR_gettid - gettid() syscall numbers in mpers
      24   */
      25  # if defined __alpha__
      26  #  define CUR_AUDIT_ARCH AUDIT_ARCH_ALPHA
      27  
      28  # elif defined __arc__
      29  #  if WORDS_BIGENDIAN
      30  #   define CUR_AUDIT_ARCH AUDIT_ARCH_ARCOMPACTBE
      31  #  else
      32  #   define CUR_AUDIT_ARCH AUDIT_ARCH_ARCOMPACT
      33  #  endif
      34  
      35  # elif defined __arm64__ || defined __aarch64__
      36  #  define CUR_AUDIT_ARCH AUDIT_ARCH_AARCH64
      37  #  define M32_AUDIT_ARCH AUDIT_ARCH_ARM
      38  #  define M32__NR_gettid 224
      39  # elif defined __arm__
      40  #  ifdef WORDS_BIGENDIAN
      41  #   define CUR_AUDIT_ARCH AUDIT_ARCH_ARMEB
      42  #  else
      43  #   define PERS0_AUDIT_ARCH AUDIT_ARCH_AARCH64
      44  #   define PERS0__NR_gettid 178
      45  #   define CUR_AUDIT_ARCH AUDIT_ARCH_ARM
      46  #  endif
      47  
      48  # elif defined __x86_64__
      49  #  define PERS0_AUDIT_ARCH AUDIT_ARCH_X86_64
      50  #  define PERS0__NR_gettid 186
      51  #  define CUR_AUDIT_ARCH AUDIT_ARCH_X86_64
      52  #  define M32_AUDIT_ARCH AUDIT_ARCH_I386
      53  #  define M32__NR_gettid 224
      54  #  define MX32_AUDIT_ARCH AUDIT_ARCH_X86_64
      55  #  define MX32__NR_gettid 1073742010
      56  # elif defined __i386__
      57  #  define PERS0_AUDIT_ARCH AUDIT_ARCH_X86_64
      58  #  ifdef X32
      59  #   define PERS0__NR_gettid 1073742010
      60  #  else
      61  #   define PERS0__NR_gettid 186
      62  #  endif
      63  #  define CUR_AUDIT_ARCH AUDIT_ARCH_I386
      64  
      65  # elif defined __ia64__
      66  #  define CUR_AUDIT_ARCH AUDIT_ARCH_IA64
      67  
      68  # elif defined __hppa__
      69  #  define CUR_AUDIT_ARCH AUDIT_ARCH_PARISC
      70  
      71  # elif defined __m68k__
      72  #  define CUR_AUDIT_ARCH AUDIT_ARCH_M68K
      73  
      74  # elif defined __mips__
      75  #  if _MIPS_SIM == _MIPS_SIM_ABI64
      76  #   ifdef WORDS_BIGENDIAN
      77  #    define CUR_AUDIT_ARCH AUDIT_ARCH_MIPS64
      78  #   else
      79  #    define CUR_AUDIT_ARCH AUDIT_ARCH_MIPSEL64
      80  #   endif
      81  #  elif _MIPS_SIM == _MIPS_SIM_NABI32
      82  #   ifdef WORDS_BIGENDIAN
      83  #    define CUR_AUDIT_ARCH AUDIT_ARCH_MIPS64N32
      84  #   else
      85  #    define CUR_AUDIT_ARCH AUDIT_ARCH_MIPSEL64N32
      86  #   endif
      87  #  elif _MIPS_SIM == _MIPS_SIM_ABI32
      88  #   ifdef WORDS_BIGENDIAN
      89  #    define CUR_AUDIT_ARCH AUDIT_ARCH_MIPS
      90  #   else
      91  #    define CUR_AUDIT_ARCH AUDIT_ARCH_MIPSEL
      92  #   endif
      93  #  endif
      94  
      95  # elif defined __powerpc64__
      96  #  ifdef WORDS_BIGENDIAN
      97  #   define CUR_AUDIT_ARCH AUDIT_ARCH_PPC64
      98  #   define M32_AUDIT_ARCH AUDIT_ARCH_PPC
      99  #   define M32__NR_gettid 207
     100  #  else
     101  #   define CUR_AUDIT_ARCH AUDIT_ARCH_PPC64LE
     102  #  endif
     103  # elif defined __powerpc__
     104  #  define PERS0_AUDIT_ARCH AUDIT_ARCH_PPC64
     105  #  define PERS0__NR_gettid 207
     106  #  define CUR_AUDIT_ARCH AUDIT_ARCH_PPC
     107  
     108  # elif defined __riscv
     109  #  define CUR_AUDIT_ARCH AUDIT_ARCH_RISCV64
     110  
     111  # elif defined __s390x__
     112  #  define CUR_AUDIT_ARCH AUDIT_ARCH_S390X
     113  #  define M32_AUDIT_ARCH AUDIT_ARCH_S390
     114  #  define M32__NR_gettid 236
     115  # elif defined __s390__
     116  #  define PERS0_AUDIT_ARCH AUDIT_ARCH_S390X
     117  #  define PERS0__NR_gettid 236
     118  #  define CUR_AUDIT_ARCH AUDIT_ARCH_S390
     119  
     120  # elif defined __sh64__
     121  #  ifdef WORDS_BIGENDIAN
     122  #   define CUR_AUDIT_ARCH AUDIT_ARCH_SH64
     123  #  else
     124  #   define CUR_AUDIT_ARCH AUDIT_ARCH_SH64EL
     125  #  endif
     126  # elif defined __sh__
     127  #  ifdef WORDS_BIGENDIAN
     128  #   define CUR_AUDIT_ARCH AUDIT_ARCH_SH
     129  #  else
     130  #   define CUR_AUDIT_ARCH AUDIT_ARCH_SHEL
     131  #  endif
     132  
     133  # elif defined __sparc__ && defined __arch64__
     134  #  define CUR_AUDIT_ARCH AUDIT_ARCH_SPARC64
     135  #  define M32_AUDIT_ARCH AUDIT_ARCH_SPARC
     136  #  define M32__NR_gettid 143
     137  # elif defined __sparc__
     138  #  define PERS0_AUDIT_ARCH AUDIT_ARCH_SPARC64
     139  #  define PERS0__NR_gettid 143
     140  #  define CUR_AUDIT_ARCH AUDIT_ARCH_SPARC
     141  
     142  # elif defined __xtensa__
     143  #  define CUR_AUDIT_ARCH AUDIT_ARCH_XTENSA
     144  
     145  # endif
     146  
     147  /* Undefine meaningless definitions */
     148  # if defined(PERS0_AUDIT_ARCH) \
     149       && !defined(MPERS_IS_m32) && !defined(MPERS_IS_mx32)
     150  #  undef PERS0_AUDIT_ARCH
     151  # endif
     152  
     153  # if defined(M32_AUDIT_ARCH) \
     154       && (!defined(HAVE_M32_MPERS) || defined(MPERS_IS_m32))
     155  #  undef M32_AUDIT_ARCH
     156  # endif
     157  
     158  # if defined(MX32_AUDIT_ARCH) \
     159       && (!defined(HAVE_MX32_MPERS) || defined(MPERS_IS_mx32))
     160  #  undef MX32_AUDIT_ARCH
     161  # endif
     162  
     163  #endif /* STRACE_TESTS_CUR_AUDIT_ARCH_H */