Skip to content

Commit 139845c

Browse files
committed
[compiler-rt] intercept macos fpurge
1 parent a738d81 commit 139845c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10263,6 +10263,21 @@ INTERCEPTOR(SSIZE_T, freadlink, int fd, char *buf, SIZE_T bufsiz) {
1026310263
# define INIT_FREADLINK
1026410264
#endif
1026510265

10266+
#if SANITIZER_INTERCEPT_FPURGE
10267+
INTERCEPTOR(int, fpurge, __sanitizer_FILE *fp) {
10268+
void *ctx;
10269+
COMMON_INTERCEPTOR_ENTER(ctx, fflush, fp);
10270+
if (fp)
10271+
unpoison_file(fp);
10272+
int res = REAL(fpurge)(fp);
10273+
if (fp) {
10274+
const FileMetadata *m = GetInterceptorMetadata(fp);
10275+
if (m) COMMON_INTERCEPTOR_INITIALIZE_RANGE(*m->addr, *m->size);
10276+
}
10277+
return res;
10278+
}
10279+
#endif
10280+
1026610281
#include "sanitizer_common_interceptors_netbsd_compat.inc"
1026710282

1026810283
namespace __sanitizer {

compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ SANITIZER_WEAK_IMPORT void *aligned_alloc(__sanitizer::usize __alignment,
640640
# define SI_MAC_OS_DEPLOYMENT_MIN_13_00 0
641641
#endif
642642
#define SANITIZER_INTERCEPT_FREADLINK (SI_MAC && SI_MAC_OS_DEPLOYMENT_MIN_13_00)
643+
#define SANITIZER_INTERCEPT_FPURGE SI_MAC
643644
// This macro gives a way for downstream users to override the above
644645
// interceptor macros irrespective of the platform they are on. They have
645646
// to do two things:

0 commit comments

Comments
 (0)