diff mbox series

[FFmpeg-devel,v2] configure: fix symbol prefix detection

Message ID D43SD7OYN2OC.3EZD39CIRSPMP@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,v2] configure: fix symbol prefix detection | expand

Checks

Context Check Description
yinshiyou/commit_msg_loongarch64 warning Please wrap lines in the body of the commit message between 60 and 72 characters.
andriy/commit_msg_x86 warning Please wrap lines in the body of the commit message between 60 and 72 characters.
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Marvin Scholz Sept. 11, 2024, 9:09 p.m. UTC
The symbol prefix check would incorrectly detect a bogus prefix in circumstances where sanitizers
instrument the build, like when configuring with the clang-asan toolchain where it would detect the
prefix as __odr_asan_gen_, which is obviously wrong.

To fix this, adjust the prefix detection to only detect a one-character prefix, which is the only case
that matters anywhere right now.
---
 configure | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)


base-commit: 2e91532ead860651c135bdedd96b6112ff715529

Comments

Martin Storsjö Sept. 12, 2024, 6:03 a.m. UTC | #1
On Wed, 11 Sep 2024, Marvin Scholz wrote:

> The symbol prefix check would incorrectly detect a bogus prefix in circumstances where sanitizers
> instrument the build, like when configuring with the clang-asan toolchain where it would detect the
> prefix as __odr_asan_gen_, which is obviously wrong.
>
> To fix this, adjust the prefix detection to only detect a one-character prefix, which is the only case
> that matters anywhere right now.
> ---
> configure | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index d3bd46f382a..7e84272b74b 100755
> --- a/configure
> +++ b/configure
> @@ -6131,13 +6131,15 @@ enable_weak_pic() {
> enabled pic && enable_weak_pic
>
> test_cc <<EOF || die "Symbol mangling check failed."
> int ff_extern;
> EOF
> -sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
> +sym=$($nm $TMPO | awk '/[ \t]+[^ \t]{0,1}ff_extern/{ print substr($0, match($0, /[^ \t]{0,1}ff_extern$/)) }')
> extern_prefix=${sym%%ff_extern*}

Since we're checking for ff_extern$ in the substr match, would it be 
safest to include the $ in the initial ff_extern match as well? So if 
there's a _ff_extern$foo symbol listed first, that won't be matched?

// Martin
Marvin Scholz Sept. 12, 2024, 9:52 p.m. UTC | #2
On 12 Sep 2024, at 8:03, Martin Storsjö wrote:

> On Wed, 11 Sep 2024, Marvin Scholz wrote:
>
>> The symbol prefix check would incorrectly detect a bogus prefix in circumstances where sanitizers
>> instrument the build, like when configuring with the clang-asan toolchain where it would detect the
>> prefix as __odr_asan_gen_, which is obviously wrong.
>>
>> To fix this, adjust the prefix detection to only detect a one-character prefix, which is the only case
>> that matters anywhere right now.
>> ---
>> configure | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/configure b/configure
>> index d3bd46f382a..7e84272b74b 100755
>> --- a/configure
>> +++ b/configure
>> @@ -6131,13 +6131,15 @@ enable_weak_pic() {
>> enabled pic && enable_weak_pic
>>
>> test_cc <<EOF || die "Symbol mangling check failed."
>> int ff_extern;
>> EOF
>> -sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
>> +sym=$($nm $TMPO | awk '/[ \t]+[^ \t]{0,1}ff_extern/{ print substr($0, match($0, /[^ \t]{0,1}ff_extern$/)) }')
>> extern_prefix=${sym%%ff_extern*}
>
> Since we're checking for ff_extern$ in the substr match, would it be safest to include the $ in the initial ff_extern match as well? So if there's a _ff_extern$foo symbol listed first, that won't be matched?
>

Indeed, sent a v3 where this is fixed.

> // Martin
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/configure b/configure
index d3bd46f382a..7e84272b74b 100755
--- a/configure
+++ b/configure
@@ -6131,13 +6131,15 @@  enable_weak_pic() {
 enabled pic && enable_weak_pic
 
 test_cc <<EOF || die "Symbol mangling check failed."
 int ff_extern;
 EOF
-sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
+sym=$($nm $TMPO | awk '/[ \t]+[^ \t]{0,1}ff_extern/{ print substr($0, match($0, /[^ \t]{0,1}ff_extern$/)) }')
 extern_prefix=${sym%%ff_extern*}
 
+log "Symbol prefix detected as: '${extern_prefix}'"
+
 ! disabled inline_asm && check_inline_asm inline_asm '"" ::'
 
 check_cc pragma_deprecated "" '_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")'
 
 test_cpp_condition stdlib.h "defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)" && enable bigendian