Avoid emitting popcnt in libclang_rt.fuzzer*.a if unsupported

Since popcnt is only supported by CPUTYPE=nehalem and later, ensure that
this instruction is only emitted when appropriate. Otherwise, programs
using the library can abort with SIGILL.

See also: https://github.com/llvm/llvm-project/issues/52893

PR:		258156
Reported by:	Eric Rucker <bhtooefr@bhtooefr.org>
MFC after:	3 days
This commit is contained in:
Dimitry Andric 2021-12-30 10:53:25 +01:00
parent 841e0a8757
commit 1331805574

View File

@ -87,7 +87,7 @@
(LIBFUZZER_APPLE || LIBFUZZER_LINUX || LIBFUZZER_NETBSD || \
LIBFUZZER_FREEBSD || LIBFUZZER_EMSCRIPTEN)
#ifdef __x86_64
#if defined(__x86_64) && defined(__POPCNT__)
#if __has_attribute(target)
#define ATTRIBUTE_TARGET_POPCNT __attribute__((target("popcnt")))
#else