shithub: dav1d

Download patch

ref: c192e0db24f01a3ea0ea32992fd0171c96ecca3a
parent: 5462c2a80de6f7f6c0b1b0d20cbe571b09510a19
author: Henrik Gramner <gramner@twoorioles.com>
date: Thu Jan 9 12:29:47 EST 2020

Add a workaround for -fsanitize=cfi + dlsym() issue

CFI will SIGILL when calling a function pointer obtained through
dlsym(), regardless of whether or not the signature is correct.

See https://bugs.llvm.org/show_bug.cgi?id=44500

--- a/include/common/attributes.h
+++ b/include/common/attributes.h
@@ -92,6 +92,12 @@
 #define NOINLINE __attribute__((noinline))
 #endif /* !_MSC_VER */
 
+#ifdef __clang__
+#define NO_SANITIZE(x) __attribute__((no_sanitize(x)))
+#else
+#define NO_SANITIZE(x)
+#endif
+
 #if defined(NDEBUG) && (defined(__GNUC__) || defined(__clang__))
 #define assert(x) do { if (!(x)) __builtin_unreachable(); } while (0)
 #elif defined(NDEBUG) && defined(_MSC_VER)
--- a/src/lib.c
+++ b/src/lib.c
@@ -79,6 +79,7 @@
 
 static void close_internal(Dav1dContext **const c_out, int flush);
 
+NO_SANITIZE("cfi-icall") // CFI is broken with dlsym()
 COLD int dav1d_open(Dav1dContext **const c_out, const Dav1dSettings *const s) {
     static pthread_once_t initted = PTHREAD_ONCE_INIT;
     pthread_once(&initted, init_internal);