-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[sanitizer_common] Implement interception on AIX #138606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -480,7 +480,7 @@ INTERCEPTOR(char*, textdomain, const char *domainname) { | |
#define INIT_TEXTDOMAIN | ||
#endif | ||
|
||
#if SANITIZER_INTERCEPT_STRCMP || SANITIZER_INTERCEPT_MEMCMP | ||
#if SANITIZER_INTERCEPT_MEMCMP | ||
static inline int CharCmpX(unsigned char c1, unsigned char c2) { | ||
return (c1 == c2) ? 0 : (c1 < c2) ? -1 : 1; | ||
} | ||
|
@@ -1350,7 +1350,8 @@ INTERCEPTOR(unsigned long, time, unsigned long *t) { | |
#if SANITIZER_INTERCEPT_LOCALTIME_AND_FRIENDS | ||
static void unpoison_tm(void *ctx, __sanitizer_tm *tm) { | ||
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, tm, sizeof(*tm)); | ||
#if !SANITIZER_SOLARIS | ||
// AIX tm struct does not have tm_zone field. | ||
# if !SANITIZER_SOLARIS && !SANITIZER_AIX | ||
if (tm->tm_zone) { | ||
// Can not use COMMON_INTERCEPTOR_WRITE_RANGE here, because tm->tm_zone | ||
// can point to shared memory and tsan would report a data race. | ||
|
@@ -1735,10 +1736,12 @@ INTERCEPTOR(int, __vsprintf_chk, char *str, int flag, SIZE_T size_to, | |
VSPRINTF_INTERCEPTOR_IMPL(vsprintf, str, format, ap) | ||
#endif | ||
|
||
# if SANITIZER_INTERCEPT_VASPRINTF | ||
INTERCEPTOR(int, vasprintf, char **strp, const char *format, va_list ap) | ||
VASPRINTF_INTERCEPTOR_IMPL(vasprintf, strp, format, ap) | ||
# endif | ||
|
||
#if SANITIZER_INTERCEPT_ISOC99_PRINTF | ||
# if SANITIZER_INTERCEPT_ISOC99_PRINTF | ||
INTERCEPTOR(int, __isoc99_vprintf, const char *format, va_list ap) | ||
VPRINTF_INTERCEPTOR_IMPL(__isoc99_vprintf, format, ap) | ||
|
||
|
@@ -1787,10 +1790,12 @@ INTERCEPTOR(int, __snprintf_chk, char *str, SIZE_T size, int flag, | |
FORMAT_INTERCEPTOR_IMPL(__snprintf_chk, vsnprintf, str, size, format) | ||
#endif | ||
|
||
# if SANITIZER_INTERCEPT_ASPRINTF | ||
INTERCEPTOR(int, asprintf, char **strp, const char *format, ...) | ||
FORMAT_INTERCEPTOR_IMPL(asprintf, vasprintf, strp, format) | ||
# endif | ||
|
||
#if SANITIZER_INTERCEPT_ISOC99_PRINTF | ||
# if SANITIZER_INTERCEPT_ISOC99_PRINTF | ||
INTERCEPTOR(int, __isoc99_printf, const char *format, ...) | ||
FORMAT_INTERCEPTOR_IMPL(__isoc99_printf, __isoc99_vprintf, format) | ||
|
||
|
@@ -1811,17 +1816,29 @@ FORMAT_INTERCEPTOR_IMPL(__isoc99_snprintf, __isoc99_vsnprintf, str, size, | |
#endif // SANITIZER_INTERCEPT_PRINTF | ||
|
||
#if SANITIZER_INTERCEPT_PRINTF | ||
#define INIT_PRINTF \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(printf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(sprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(snprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(asprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(fprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vsprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vsnprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vasprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vfprintf); | ||
# if SANITIZER_AIX | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the list is rather long and the difference is near the end, a comment would help: |
||
# define INIT_PRINTF \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(printf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(sprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(snprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(fprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vsprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vsnprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vfprintf); | ||
# else | ||
# define INIT_PRINTF \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(printf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(sprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(snprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(fprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vsprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vsnprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(asprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vasprintf); \ | ||
COMMON_INTERCEPT_FUNCTION_LDBL(vfprintf); | ||
# endif | ||
#else | ||
#define INIT_PRINTF | ||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,8 @@ | |
#define PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE 0 | ||
#elif SANITIZER_WINDOWS64 | ||
#define PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE 0 | ||
#elif SANITIZER_AIX | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please reformat entire block starting from #if SANITIZER_APPLE |
||
# define PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE 0 | ||
#else | ||
#define PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE 1 | ||
#endif // SANITIZER_APPLE | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
# define SANITIZER_REDEFINE_BUILTINS_H | ||
|
||
// The asm hack only works with GCC and Clang. | ||
# if !defined(_WIN32) | ||
# if !defined(_WIN32) && !defined(_AIX) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not on AIX? |
||
|
||
asm(R"( | ||
.set memcpy, __sanitizer_internal_memcpy | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[[maybe_unused]]?
This way we will at leas compile the code on platform where it's disabled - can catch compilation breckages earlies.