[PATCH] D58379: [compiler-rt] Intercept the bcmp() function.
Clement Courbet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 19 01:45:03 PST 2019
courbet marked an inline comment as done.
courbet added inline comments.
================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:874
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, bcmp, a1, a2, size);
+ if (common_flags()->intercept_memcmp) {
----------------
krytarowski wrote:
> Can we reuse code with memcmp(3)? bcmp(3) is a subset of memcmp(3).
Looking at `COMMON_INTERCEPTOR_ENTER` implementation for, e.g. tsan:
```
#define SCOPED_TSAN_INTERCEPTOR(func, ...) \
SCOPED_INTERCEPTOR_RAW(func, __VA_ARGS__); \
if (REAL(func) == 0) { \
Printf("FATAL: ThreadSanitizer: failed to intercept %s\n", #func); \
Die(); \
} \
if (thr->in_rtl > 1) \
return REAL(func)(__VA_ARGS__);
#define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \
SCOPED_TSAN_INTERCEPTOR(func, __VA_ARGS__); \
TsanInterceptorContext _ctx = {thr, caller_pc, pc}; \
ctx = (void *)&_ctx; \
(void) ctx;
```
Given that the implementation calls `REAL(func)`, it feels preferable to call the real `bcmp` instead of real `memcmp`, even though calling memcmp does work. But again, I'm not familiar with how you guys typically approach this, so you tell me :)
Repository:
rCRT Compiler Runtime
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58379/new/
https://reviews.llvm.org/D58379
More information about the llvm-commits
mailing list