@@ -333,7 +333,7 @@ INTERCEPTOR(int, pthread_timedjoin_np, void *thread, void **ret,
333333}
334334# endif
335335
336- DEFINE_REAL_PTHREAD_FUNCTIONS
336+ DEFINE_INTERNAL_PTHREAD_FUNCTIONS
337337#endif // ASAN_INTERCEPT_PTHREAD_CREATE
338338
339339#if ASAN_INTERCEPT_SWAPCONTEXT
@@ -352,8 +352,16 @@ static void ClearShadowMemoryForContextStack(uptr stack, uptr ssize) {
352352 PoisonShadow (bottom, ssize, 0 );
353353}
354354
355+ // Since Solaris 10/SPARC, ucp->uc_stack.ss_sp refers to the stack base address
356+ // as on other targets. For binary compatibility, the new version uses a
357+ // different external name, so we intercept that.
358+ # if SANITIZER_SOLARIS && defined(__sparc__)
359+ INTERCEPTOR (void , __makecontext_v2, struct ucontext_t *ucp, void (*func)(),
360+ int argc, ...) {
361+ # else
355362INTERCEPTOR (void , makecontext, struct ucontext_t *ucp, void (*func)(), int argc,
356363 ...) {
364+ # endif
357365 va_list ap;
358366 uptr args[64 ];
359367 // We don't know a better way to forward ... into REAL function. We can
@@ -373,7 +381,11 @@ INTERCEPTOR(void, makecontext, struct ucontext_t *ucp, void (*func)(), int argc,
373381 ENUMERATE_ARRAY_16 (0 ), ENUMERATE_ARRAY_16 (16 ), ENUMERATE_ARRAY_16 (32 ), \
374382 ENUMERATE_ARRAY_16 (48 )
375383
384+ # if SANITIZER_SOLARIS && defined(__sparc__)
385+ REAL (__makecontext_v2)
386+ # else
376387 REAL (makecontext)
388+ # endif
377389 ((struct ucontext_t *)ucp, func, argc, ENUMERATE_ARRAY_64 ());
378390
379391# undef ENUMERATE_ARRAY_4
@@ -558,6 +570,17 @@ INTERCEPTOR(char *, strcpy, char *to, const char *from) {
558570 return REAL (strcpy)(to, from);
559571}
560572
573+ // Windows doesn't always define the strdup identifier,
574+ // and when it does it's a macro defined to either _strdup
575+ // or _strdup_dbg, _strdup_dbg ends up calling _strdup, so
576+ // we want to intercept that. push/pop_macro are used to avoid problems
577+ // if this file ends up including <string.h> in the future.
578+ # if SANITIZER_WINDOWS
579+ # pragma push_macro("strdup")
580+ # undef strdup
581+ # define strdup _strdup
582+ # endif
583+
561584INTERCEPTOR (char *, strdup, const char *s) {
562585 void *ctx;
563586 ASAN_INTERCEPTOR_ENTER (ctx, strdup);
@@ -575,7 +598,7 @@ INTERCEPTOR(char*, strdup, const char *s) {
575598 return reinterpret_cast <char *>(new_mem);
576599}
577600
578- #if ASAN_INTERCEPT___STRDUP
601+ # if ASAN_INTERCEPT___STRDUP
579602INTERCEPTOR (char *, __strdup, const char *s) {
580603 void *ctx;
581604 ASAN_INTERCEPTOR_ENTER (ctx, strdup);
@@ -724,7 +747,7 @@ INTERCEPTOR(int, atexit, void (*func)()) {
724747extern " C" {
725748extern int _pthread_atfork (void (*prepare)(), void (*parent)(),
726749 void (*child)());
727- };
750+ }
728751
729752INTERCEPTOR (int , pthread_atfork, void (*prepare)(), void (*parent)(),
730753 void (*child)()) {
@@ -738,8 +761,8 @@ INTERCEPTOR(int, pthread_atfork, void (*prepare)(), void (*parent)(),
738761#endif
739762
740763#if ASAN_INTERCEPT_VFORK
741- DEFINE_REAL (int , vfork)
742- DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(int , vfork)
764+ DEFINE_REAL (int , vfork, )
765+ DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER (int , vfork, )
743766#endif
744767
745768// ---------------------- InitializeAsanInterceptors ---------------- {{{1
@@ -758,7 +781,7 @@ void InitializeAsanInterceptors() {
758781 ASAN_INTERCEPT_FUNC (strncat);
759782 ASAN_INTERCEPT_FUNC (strncpy);
760783 ASAN_INTERCEPT_FUNC (strdup);
761- #if ASAN_INTERCEPT___STRDUP
784+ # if ASAN_INTERCEPT___STRDUP
762785 ASAN_INTERCEPT_FUNC (__strdup);
763786#endif
764787#if ASAN_INTERCEPT_INDEX && ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX
@@ -780,7 +803,12 @@ void InitializeAsanInterceptors() {
780803
781804# if ASAN_INTERCEPT_SWAPCONTEXT
782805 ASAN_INTERCEPT_FUNC (swapcontext);
806+ // See the makecontext interceptor above for an explanation.
807+ # if SANITIZER_SOLARIS && defined(__sparc__)
808+ ASAN_INTERCEPT_FUNC (__makecontext_v2);
809+ # else
783810 ASAN_INTERCEPT_FUNC (makecontext);
811+ # endif
784812# endif
785813# if ASAN_INTERCEPT__LONGJMP
786814 ASAN_INTERCEPT_FUNC (_longjmp);
@@ -849,6 +877,10 @@ void InitializeAsanInterceptors() {
849877 VReport (1 , " AddressSanitizer: libc interceptors initialized\n " );
850878}
851879
880+ # if SANITIZER_WINDOWS
881+ # pragma pop_macro("strdup")
882+ # endif
883+
852884} // namespace __asan
853885
854886#endif // !SANITIZER_FUCHSIA && !SANITIZER_RTEMS && !SANITIZER_EMSCRIPTEN
0 commit comments