Skip to contentSkip to conversation

configure: fix --enable-fuzzing linker failures

PATCH Superseded Alexander Bulekov 2 participants 4 messages Feb 21, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure: fix --enable-fuzzing linker failures

With --enable-fuzzing, QEMU_CFLAGS include -fsanitize=fuzzer-no-link. This should allow us to build non-fuzzer binaries using objects instrumented for fuzzing. However, to do that, we also need to link with -fsanitize=fuzzer-no-link. We were not doing that.

---
 configure | 1 +
 1 file changed, 1 insertion(+)
configure +1 -0
index a79b3746d4..02aaea31c8 100755
@@ -6097,6 +6097,7 @@ if test "$fuzzing" = "yes" ; then
   # needed CFLAGS have already been provided
   if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
     QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
+    QEMU_LDFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
     FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer"
   else
     FUZZ_EXE_LDFLAGS="$LIB_FUZZING_ENGINE"
Signature · 1 line
2.27.0
#1 lore raw
Quoted 17 lines · Alexander Bulekov

With --enable-fuzzing, QEMU_CFLAGS include -fsanitize=fuzzer-no-link. This should allow us to build non-fuzzer binaries using objects instrumented for fuzzing. However, to do that, we also need to link with -fsanitize=fuzzer-no-link. We were not doing that.

---
 configure | 1 +
 1 file changed, 1 insertion(+)
configure +0 -0
index a79b3746d4..02aaea31c8 100755

configure if test "$fuzzing" = "yes" ; then · line 6100

Quoted 4 lines
configure +1 -0
@@ -6097,6 +6097,7 @@ if test "$fuzzing" = "yes" ; then
   # needed CFLAGS have already been provided
   if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
     QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
+    QEMU_LDFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"

Did you mean ="$QEMU_LDFLAGS ... ?

configure if test "$fuzzing" = "yes" ; then · line 6101

Quoted 1 line
configure +0 -0
     FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer"

-- PMM

#2 lore raw
Quoted 13 lines · Peter Maydell
Quoted 12 lines · Alexander Bulekov

With --enable-fuzzing, QEMU_CFLAGS include -fsanitize=fuzzer-no-link. This should allow us to build non-fuzzer binaries using objects instrumented for fuzzing. However, to do that, we also need to link with -fsanitize=fuzzer-no-link. We were not doing that.

---
 configure | 1 +
 1 file changed, 1 insertion(+)
Quoted 11 lines

configure if test "$fuzzing" = "yes" ; then · line 6100

Quoted 9 lines
configure +1 -0
index a79b3746d4..02aaea31c8 100755
@@ -6097,6 +6097,7 @@ if test "$fuzzing" = "yes" ; then
   # needed CFLAGS have already been provided
   if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
     QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
+    QEMU_LDFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"

Did you mean ="$QEMU_LDFLAGS ... ?

Yes... It somehow passed my build-test. Should I send a v2?

Quoted 4 lines

configure if test "$fuzzing" = "yes" ; then · line 6101

Quoted 2 lines
configure +0 -0
     FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer"

-- PMM

#3 lore raw
Quoted 27 lines · Alexander Bulekov
Quoted 13 lines · Peter Maydell
Quoted 12 lines · Alexander Bulekov

With --enable-fuzzing, QEMU_CFLAGS include -fsanitize=fuzzer-no-link. This should allow us to build non-fuzzer binaries using objects instrumented for fuzzing. However, to do that, we also need to link with -fsanitize=fuzzer-no-link. We were not doing that.

---
 configure | 1 +
 1 file changed, 1 insertion(+)
Quoted 11 lines

configure if test "$fuzzing" = "yes" ; then · line 6100

Quoted 9 lines
configure +1 -0
index a79b3746d4..02aaea31c8 100755
@@ -6097,6 +6097,7 @@ if test "$fuzzing" = "yes" ; then
   # needed CFLAGS have already been provided
   if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
     QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
+    QEMU_LDFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"

Did you mean ="$QEMU_LDFLAGS ... ?

Quoted 1 line

Yes... It somehow passed my build-test. Should I send a v2?

Yes, please.

Quoted 1 line
Quoted 1 line

configure if test "$fuzzing" = "yes" ; then · line 6101

Quoted 1 line
configure +0 -0
     FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer"

It might also be helpful to have a brief comment explaining why we need to set fuzzing related options in all three of QEMU_CFLAGS, QEMU_LDFLAGS and FUZZ_EXE_LDFLAGS (ie what the difference between them is).

-- PMM