From 6db43f9142103887037ef42fca1295d1c8365f66 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 11 Sep 2023 09:46:03 -0400 Subject: [PATCH] MT#55283 further defuse ifunc on non-x86 targets Some gcc targets report ifunc as a supported attribute, while at the same time actually trying to build the object fails with "ifunc not supported on this target". Be more prejudicial with ifunc usage. Change-Id: I5820338476938bf581d6d9e38fe0e6fd48f0b874 (cherry picked from commit 80014423c3007a791d74cda5d6bfc0671d47990c) --- lib/codeclib.c | 49 +++++++++++++++++++++--------------------------- lib/mix_buffer.c | 4 +--- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/lib/codeclib.c b/lib/codeclib.c index c8dd7d2cf..0b332ce04 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -37,16 +37,6 @@ static packetizer_f packetizer_samplestream; // flat stream of samples static packetizer_f packetizer_amr; -#if !defined(ASAN_BUILD) && HAS_ATTR(ifunc) -static void (*resolve_float2int16_array(void))(float *, const uint16_t, int16_t *); -static void float2int16_array(float *in, const uint16_t len, int16_t *out) - __attribute__ ((ifunc ("resolve_float2int16_array"))); -#else -#define float2int16_array evs_syn_output -#endif - - - static void codeclib_key_value_parse(const str *instr, bool need_value, void (*cb)(str *key, str *value, void *data), void *data); @@ -3378,24 +3368,6 @@ void frame_fill_dtmf_samples(enum AVSampleFormat fmt, void *samples, unsigned in -static void mvr2s_dynlib_wrapper(float *in, const uint16_t len, int16_t *out) { - evs_syn_output(in, len, out); -} - -static void (*resolve_float2int16_array(void))(float *, const uint16_t, int16_t *) { -#if defined(__x86_64__) - if (rtpe_has_cpu_flag(RTPE_CPU_FLAG_AVX512BW) && rtpe_has_cpu_flag(RTPE_CPU_FLAG_AVX512F)) - return mvr2s_avx512; - if (rtpe_has_cpu_flag(RTPE_CPU_FLAG_AVX2)) - return mvr2s_avx2; -#endif - return mvr2s_dynlib_wrapper; -} - - - - - // lamely parse out decimal numbers without using floating point static unsigned int str_to_i_k(str *s) { str intg; @@ -4304,6 +4276,27 @@ static const char evs_amr_io_compact_cmr[8] = { }; +#if defined(__x86_64__) && !defined(ASAN_BUILD) && HAS_ATTR(ifunc) +static void mvr2s_dynlib_wrapper(float *in, const uint16_t len, int16_t *out) { + evs_syn_output(in, len, out); +} +static void (*resolve_float2int16_array(void))(float *, const uint16_t, int16_t *) { +#if defined(__x86_64__) + if (rtpe_has_cpu_flag(RTPE_CPU_FLAG_AVX512BW) && rtpe_has_cpu_flag(RTPE_CPU_FLAG_AVX512F)) + return mvr2s_avx512; + if (rtpe_has_cpu_flag(RTPE_CPU_FLAG_AVX2)) + return mvr2s_avx2; +#endif + return mvr2s_dynlib_wrapper; +} +static void float2int16_array(float *in, const uint16_t len, int16_t *out) + __attribute__ ((ifunc ("resolve_float2int16_array"))); +#else +#define float2int16_array evs_syn_output +#endif + + + static int evs_decoder_input(decoder_t *dec, const str *data, GQueue *out) { str input = *data; uint64_t pts = dec->pts; diff --git a/lib/mix_buffer.c b/lib/mix_buffer.c index 511ffd6fd..48566caf2 100644 --- a/lib/mix_buffer.c +++ b/lib/mix_buffer.c @@ -53,16 +53,14 @@ static void s16_mix_in_c(void *restrict dst, const void *restrict src, unsigned } -#if !defined(ASAN_BUILD) && HAS_ATTR(ifunc) +#if defined(__x86_64__) && !defined(ASAN_BUILD) && HAS_ATTR(ifunc) static mix_in_fn_t *resolve_s16_mix_in(void) { -#if defined(__x86_64__) if (rtpe_has_cpu_flag(RTPE_CPU_FLAG_AVX512BW)) return s16_mix_in_avx512; if (rtpe_has_cpu_flag(RTPE_CPU_FLAG_AVX2)) return s16_mix_in_avx2; if (rtpe_has_cpu_flag(RTPE_CPU_FLAG_SSE2)) return s16_mix_in_sse2; -#endif return s16_mix_in_c; } static mix_in_fn_t s16_mix_in __attribute__ ((ifunc ("resolve_s16_mix_in")));