-
Notifications
You must be signed in to change notification settings - Fork 4
/
crc64_fast.c.diff
31 lines (27 loc) · 1.27 KB
/
crc64_fast.c.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
diff --git a/crc64_fast.c.o b/crc64_fast.c.m
index 52cddb2..3b69293 100755
--- a/crc64_fast.c.o
+++ b/crc64_fast.c.m
@@ -1,3 +1,4 @@
+# 0 "/mnt/c/Users/xxx/Downloads/xz-cve-2024-3094/xz-5.6.1/src/liblzma/check/crc64_fast.c"
// SPDX-License-Identifier: 0BSD
///////////////////////////////////////////////////////////////////////////////
@@ -17,6 +18,12 @@
# define BUILDING_CRC64_CLMUL
# include "crc_x86_clmul.h"
#endif
+#if defined(CRC32_GENERIC) && defined(CRC64_GENERIC) && defined(CRC_X86_CLMUL) && defined(CRC_USE_IFUNC) && defined(PIC) && (defined(BUILDING_CRC64_CLMUL) || defined(BUILDING_CRC32_CLMUL))
+extern int _get_cpuid(int, void*, void*, void*, void*, void*);
+static inline bool _is_arch_extension_supported(void) { int success = 1; uint32_t r[4]; success = _get_cpuid(1, &r[0], &r[1], &r[2], &r[3], ((char*) __builtin_frame_address(0))-16); const uint32_t ecx_mask = (1 << 1) | (1 << 9) | (1 << 19); return success && (r[2] & ecx_mask) == ecx_mask; }
+#else
+#define _is_arch_extension_supported is_arch_extension_supported
+#endif
#ifdef CRC64_GENERIC
@@ -102,7 +109,7 @@ lzma_resolver_attributes
static crc64_func_type
crc64_resolve(void)
{
- return is_arch_extension_supported()
+return _is_arch_extension_supported()
? &crc64_arch_optimized : &crc64_generic;
}