From: Eugene Syromyatnikov Date: Sun, 11 Dec 2016 13:30:30 +0000 (+0300) Subject: Introduce current_klongsize in addition to current_wordsize X-Git-Tag: v4.16~333 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1fe5d9bed56009091dcdec69e0054921de602687;p=strace Introduce current_klongsize in addition to current_wordsize Subsequent commits are going to use current_klongsize as the tracee's size of kernel_ulong_t type. * defs.h (PERSONALITY0_KLONGSIZE): New macro. [X86_64] (PERSONALITY2_KLONGSIZE): Likewise. [SUPPORTED_PERSONALITIES > 1] (PERSONALITY1_KLONGSIZE): Likewise. [SUPPORTED_PERSONALITIES == 1] (current_klongsize): Likewise. [SUPPORTED_PERSONALITIES == 2 && PERSONALITY0_KLONGSIZE == PERSONALITY1_KLONGSIZE] (current_klongsize): Likewise. [SUPPORTED_PERSONALITIES != 1 && (SUPPORTED_PERSONALITIES != 2 || PERSONALITY0_KLONGSIZE != PERSONALITY1_KLONGSIZE)] (current_klongsize): New variable prototype. * syscall.c [!current_klongsize] (current_klongsize): New variable. [!current_klongsize] (personality_klongsize): New array. (set_personality) [!current_klongsize]: Update current_klongsize with the appropriate value from personality_klongsize. --- diff --git a/defs.h b/defs.h index f5d0ecbe..758f2e70 100644 --- a/defs.h +++ b/defs.h @@ -150,7 +150,8 @@ extern char *stpcpy(char *dst, const char *src); #if defined X86_64 # define SUPPORTED_PERSONALITIES 3 -# define PERSONALITY2_WORDSIZE 4 +# define PERSONALITY2_WORDSIZE 4 +# define PERSONALITY2_KLONGSIZE PERSONALITY0_KLONGSIZE #elif defined AARCH64 \ || defined POWERPC64 \ || defined RISCV \ @@ -168,12 +169,14 @@ extern char *stpcpy(char *dst, const char *src); # define DEFAULT_PERSONALITY 0 #endif -#define PERSONALITY0_WORDSIZE SIZEOF_LONG +#define PERSONALITY0_WORDSIZE SIZEOF_LONG +#define PERSONALITY0_KLONGSIZE SIZEOF_KERNEL_LONG_T #define PERSONALITY0_INCLUDE_PRINTERS_DECLS "native_printer_decls.h" #define PERSONALITY0_INCLUDE_PRINTERS_DEFS "native_printer_defs.h" #if SUPPORTED_PERSONALITIES > 1 -# define PERSONALITY1_WORDSIZE 4 +# define PERSONALITY1_WORDSIZE 4 +# define PERSONALITY1_KLONGSIZE PERSONALITY1_WORDSIZE #endif #if SUPPORTED_PERSONALITIES > 1 && defined HAVE_M32_MPERS @@ -792,12 +795,18 @@ extern unsigned current_personality; #if SUPPORTED_PERSONALITIES == 1 # define current_wordsize PERSONALITY0_WORDSIZE +# define current_klongsize PERSONALITY0_KLONGSIZE #else # if SUPPORTED_PERSONALITIES == 2 && PERSONALITY0_WORDSIZE == PERSONALITY1_WORDSIZE # define current_wordsize PERSONALITY0_WORDSIZE # else extern unsigned current_wordsize; # endif +# if SUPPORTED_PERSONALITIES == 2 && PERSONALITY0_KLONGSIZE == PERSONALITY1_KLONGSIZE +# define current_klongsize PERSONALITY0_KLONGSIZE +# else +extern unsigned current_klongsize; +# endif #endif /* In many, many places we play fast and loose and use diff --git a/syscall.c b/syscall.c index 81489af7..e346958c 100644 --- a/syscall.c +++ b/syscall.c @@ -257,6 +257,17 @@ static const int personality_wordsize[SUPPORTED_PERSONALITIES] = { }; # endif +# ifndef current_klongsize +unsigned current_klongsize; +static const int personality_klongsize[SUPPORTED_PERSONALITIES] = { + PERSONALITY0_KLONGSIZE, + PERSONALITY1_KLONGSIZE, +# if SUPPORTED_PERSONALITIES > 2 + PERSONALITY2_KLONGSIZE, +# endif +}; +# endif + void set_personality(int personality) { @@ -301,6 +312,9 @@ set_personality(int personality) # ifndef current_wordsize current_wordsize = personality_wordsize[personality]; # endif +# ifndef current_klongsize + current_klongsize = personality_klongsize[personality]; +# endif } static void