From: Szabolcs Nagy Date: Tue, 15 Dec 2015 18:32:17 +0000 (+0000) Subject: Fix SYS_FUNC and SEN macros for musl X-Git-Tag: v4.11~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34683e3926d8c2daa368afb805da422ee7043396;p=strace Fix SYS_FUNC and SEN macros for musl The syscall_name argument was subject to macro expansion because it was passed down to other macros before it was prefixed. musl libc defines lfs64 names as macros (e.g. fstat64 as fstat) so SYS_FUNC(fstat64) was expanded to sys_fstat. This change adds the prefix before the name is passed to other macros, i.e. the argument of SYS_FUNC_NAME is already prefixed with sys_. * defs.h (SYS_FUNC): Add sys_ prefix to SYS_FUNC_NAME's argument. (SYS_FUNC_NAME): Do not add sys_ prefix to MPERS_FUNC_NAME's argument. * linux/ia64/syscallent.h (SYS_FUNC_NAME): Do not add sys_ prefix to MPERS_FUNC_NAME's argument. * syscall.c (SEN_NAME): Remove. (SEN): Replace SEN_NAME call with its definition. Add sys_ prefix to SYS_FUNC_NAME's argument. --- diff --git a/defs.h b/defs.h index 1aca4e2d..283ab1fe 100644 --- a/defs.h +++ b/defs.h @@ -800,8 +800,8 @@ extern unsigned num_quals; #define MPERS_FUNC_NAME_(prefix, name) MPERS_FUNC_NAME__(prefix, name) #define MPERS_FUNC_NAME(name) MPERS_FUNC_NAME_(MPERS_PREFIX, name) -#define SYS_FUNC_NAME(syscall_name) MPERS_FUNC_NAME(sys_ ## syscall_name) +#define SYS_FUNC_NAME(syscall_name) MPERS_FUNC_NAME(syscall_name) -#define SYS_FUNC(syscall_name) int SYS_FUNC_NAME(syscall_name)(struct tcb *tcp) +#define SYS_FUNC(syscall_name) int SYS_FUNC_NAME(sys_ ## syscall_name)(struct tcb *tcp) #define MPERS_PRINTER_DECL(type, name) type MPERS_FUNC_NAME(name) diff --git a/linux/ia64/syscallent.h b/linux/ia64/syscallent.h index 3bfa3479..b34712c2 100644 --- a/linux/ia64/syscallent.h +++ b/linux/ia64/syscallent.h @@ -34,7 +34,7 @@ #define SYS_FUNC_NAME(syscall_name) printargs #include "../i386/syscallent.h" #undef SYS_FUNC_NAME -#define SYS_FUNC_NAME(syscall_name) MPERS_FUNC_NAME(sys_ ## syscall_name) +#define SYS_FUNC_NAME(syscall_name) MPERS_FUNC_NAME(syscall_name) /* You must be careful to check ../i386/syscallent.h so that this table starts where that one leaves off. diff --git a/syscall.c b/syscall.c index 66154f7e..8d81274a 100644 --- a/syscall.c +++ b/syscall.c @@ -82,8 +82,7 @@ #define SI STACKTRACE_INVALIDATE_CACHE #define SE STACKTRACE_CAPTURE_ON_ENTER -#define SEN_NAME(syscall_name) SEN_ ## syscall_name -#define SEN(syscall_name) SEN_NAME(syscall_name), SYS_FUNC_NAME(syscall_name) +#define SEN(syscall_name) SEN_ ## syscall_name, SYS_FUNC_NAME(sys_ ## syscall_name) const struct_sysent sysent0[] = { #include "syscallent.h" @@ -105,7 +104,6 @@ static const struct_sysent sysent2[] = { /* Now undef them since short defines cause wicked namespace pollution. */ #undef SEN -#undef SEN_NAME #undef TD #undef TF #undef TI