PR #23543 opened by catap
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23543
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23543.patch

The existing x86_32_7regs probe keeps HAVE_7REGS from
relying on the EBP crash probe. HAVE_6REGS still used
HAVE_EBX_AVAILABLE || HAVE_EBP_AVAILABLE, which has the same
problem: an EBP clobber probe can pass even when the compiler
cannot allocate the multi-register asm patterns guarded by
HAVE_6REGS.

Add an x86_32_6regs probe and use it for HAVE_6REGS.

# Summary of changes

Briefly describe what this PR does and why.

<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).

Attached filenames must match the sample's filename:

```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->



>From a267e61bca0a1c47fd3266d62bbe0a75c015fe12 Mon Sep 17 00:00:00 2001
From: "Kirill A. Korinsky" <[email protected]>
Date: Sat, 20 Jun 2026 23:42:55 +0200
Subject: [PATCH] configure/x86: test 6-register inline asm separately

The existing x86_32_7regs probe keeps HAVE_7REGS from
relying on the EBP crash probe. HAVE_6REGS still used
HAVE_EBX_AVAILABLE || HAVE_EBP_AVAILABLE, which has the same
problem: an EBP clobber probe can pass even when the compiler
cannot allocate the multi-register asm patterns guarded by
HAVE_6REGS.

Add an x86_32_6regs probe and use it for HAVE_6REGS.
---
 configure           | 9 +++++++--
 libavutil/x86/asm.h | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index a6bbb86807..26bf649788 100755
--- a/configure
+++ b/configure
@@ -2656,6 +2656,7 @@ TOOLCHAIN_FEATURES="
     symver_asm_label
     symver_gnu_asm
     vfp_args
+    x86_32_6regs
     x86_32_7regs
     xform_asm
     xmm_clobbers
@@ -6850,11 +6851,14 @@ EOF
     check_inline_asm ebx_available '""::"b"(0)' &&
         check_inline_asm ebx_available '"":::"%ebx"'
 
-    # check whether 7 registers are available on x86-32
+    # check whether 6 and 7 registers are available on x86-32
     # Since 
https://github.com/llvm/llvm-project/commit/0d471b3f64d3116bd57c79d872f7384fff80daa5,
     # Clang can save/restore EBP around clobber-only asm, so the EBP
-    # crash probe alone can be a false positive for 7-register asm.
+    # crash probe alone can be a false positive for multi-register asm.
+    disable x86_32_6regs
     disable x86_32_7regs
+    enabled x86_32 && enabled_any ebx_available ebp_available &&
+        check_inline_asm x86_32_6regs '"" :: "r"(0), "r"(1), "r"(2), "r"(3), 
"g"(4) : "%eax", "%edx"'
     enabled_all x86_32 ebx_available ebp_available &&
         check_inline_asm x86_32_7regs '"" :: "r"(0), "r"(1), "r"(2), "r"(3), 
"g"(4), "r"(5) : "%eax", "%edx"'
 
@@ -8519,6 +8523,7 @@ if enabled x86; then
     echo "EBP available             ${ebp_available-no}"
 fi
 if enabled x86_32; then
+    echo "6 registers available     ${x86_32_6regs-no}"
     echo "7 registers available     ${x86_32_7regs-no}"
 fi
 if enabled aarch64; then
diff --git a/libavutil/x86/asm.h b/libavutil/x86/asm.h
index fc9f50b1a9..21b95cbba1 100644
--- a/libavutil/x86/asm.h
+++ b/libavutil/x86/asm.h
@@ -72,7 +72,7 @@ typedef int x86_reg;
 #endif
 
 #define HAVE_7REGS (ARCH_X86_64 || HAVE_X86_32_7REGS)
-#define HAVE_6REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE || HAVE_EBP_AVAILABLE))
+#define HAVE_6REGS (ARCH_X86_64 || HAVE_X86_32_6REGS)
 
 #if ARCH_X86_64 && defined(PIC)
 #    define BROKEN_RELOCATIONS 1
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to