Hello,

See the attached log snippet.  This is current staging, with a GCC 13
toolchain.

First of all, a minor issue.  Counting the number of
`-D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__`'s, we
have included CFLAGS on the CC line 4 times.  This is something that
appears to be in common with all of tools/ and is probably the primary
contributor to exceeding the Gitlab CI 4M log limit...

Next the error.  This doesn't build when CFLAGS coming in from the
packaging environment include `-flto=auto`.

Clearly our wrapping trick doesn't work with LTO, but it's not obvious why.

readelf -Wa tools/fuzz/x86_instruction_emulator/wrappers.o | grep emul_
  [223] .gnu.lto_emul_fwrite.38.43da3a7fd30cc0a1 PROGBITS       
0000000000000000 01c2ec 000194 00   E  0   0  1
  [224] .gnu.lto_emul_memcmp.39.43da3a7fd30cc0a1 PROGBITS       
0000000000000000 01c480 0001a7 00   E  0   0  1
  [225] .gnu.lto_emul_memcpy.40.43da3a7fd30cc0a1 PROGBITS       
0000000000000000 01c627 000175 00   E  0   0  1
  [226] .gnu.lto_emul_memset.41.43da3a7fd30cc0a1 PROGBITS       
0000000000000000 01c79c 000186 00   E  0   0  1
  [227] .gnu.lto_emul_printf.42.43da3a7fd30cc0a1 PROGBITS       
0000000000000000 01c922 0002cd 00   E  0   0  1
  [228] .gnu.lto_emul_putchar.43.43da3a7fd30cc0a1 PROGBITS       
0000000000000000 01cbef 000216 00   E  0   0  1
  [229] .gnu.lto_emul_puts.44.43da3a7fd30cc0a1 PROGBITS       
0000000000000000 01ce05 000180 00   E  0   0  1

shows that there's something relevant in the object file.

Manual poking about in the build environment indicates that
tools/tests/x86_instruction_emulator is similarly impacted.

Any ideas?

Obviously we can inhibit LTO for the x86_emul userspace, but that ought
to be a last resort.

~Andrew
make[5]: Entering directory '/builddir/build/BUILD/xen-4.18.0/tools/fuzz/x86_instruction_emulator'
gcc -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/xenserver/xenserver-hardened-cc1 -fstack-protector-strong  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs   -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs   -g3 -Werror -Og -fno-omit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MP -MF .subdirs-all.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE   -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs   -g3 -Werror -Og -fno-omit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MP -MF .subdir-all-fuzz.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE   -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs   -g3 -Werror -Og -fno-omit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MP -MF .subdirs-all.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE   -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs   -g3 -Werror -Og -fno-omit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MP -MF .subdir-all-x86_instruction_emulator.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE   -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs   -g3 -Werror -Og -fno-omit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MP -MF .afl-harness.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE   -I/builddir/build/BUILD/xen-4.18.0/tools/fuzz/x86_instruction_emulator/../../../tools/include -D__XEN_TOOLS__ -iquote . afl-harness.o fuzz-emul.o x86-emulate.o x86_emulate/0f01.o x86_emulate/0fae.o x86_emulate/0fc7.o x86_emulate/decode.o x86_emulate/fpu.o cpuid.o wrappers.o -o afl-harness
make[5]: Leaving directory '/builddir/build/BUILD/xen-4.18.0/tools/fuzz/x86_instruction_emulator'
/usr/bin/ld: /tmp/ccphSQcS.ltrans0.ltrans.o: in function `disable_hooks':
/usr/include/bits/stdio2.h:86: undefined reference to `emul_puts'
/usr/bin/ld: /usr/include/bits/stdio2.h:86: undefined reference to `emul_puts'
/usr/bin/ld: /usr/include/bits/stdio2.h:86: undefined reference to `emul_puts'
/usr/bin/ld: /usr/include/bits/stdio2.h:86: undefined reference to `emul_puts'
/usr/bin/ld: /usr/include/bits/stdio2.h:86: undefined reference to `emul_puts'
/usr/bin/ld: /tmp/ccphSQcS.ltrans0.ltrans.o:/usr/include/bits/stdio2.h:86: more undefined references to `emul_puts' follow
/usr/bin/ld: /tmp/ccphSQcS.ltrans0.ltrans.o: in function `input_read':
/usr/include/bits/string_fortified.h:29: undefined reference to `emul_memcpy'
/usr/bin/ld: /tmp/ccphSQcS.ltrans0.ltrans.o: in function `data_read':
/usr/include/bits/stdio2.h:86: undefined reference to `emul_putchar'
/usr/bin/ld: /tmp/ccphSQcS.ltrans0.ltrans.o: in function `fuzz_read_msr':
/usr/include/bits/stdio2.h:86: undefined reference to `emul_puts'
/usr/bin/ld: /tmp/ccphSQcS.ltrans0.ltrans.o: in function `dump_state':
/usr/include/bits/stdio2.h:86: undefined reference to `emul_puts'
/usr/bin/ld: /tmp/ccphSQcS.ltrans0.ltrans.o: in function `LLVMFuzzerTestOneInput':
/usr/include/bits/stdio2.h:86: undefined reference to `emul_puts'
/usr/bin/ld: /usr/include/bits/stdio2.h:86: undefined reference to `emul_puts'
/usr/bin/ld: /tmp/ccphSQcS.ltrans0.ltrans.o: in function `main':
/usr/include/bits/stdio2.h:86: undefined reference to `emul_puts'
/usr/bin/ld: /tmp/ccphSQcS.ltrans0.ltrans.o: in function `x86_emulate':
/usr/include/bits/string_fortified.h:29: undefined reference to `emul_memcpy'
/usr/bin/ld: /usr/include/bits/string_fortified.h:59: undefined reference to `emul_memset'
/usr/bin/ld: /usr/include/bits/string_fortified.h:59: undefined reference to `emul_memset'
/usr/bin/ld: /usr/include/bits/string_fortified.h:59: undefined reference to `emul_memset'
/usr/bin/ld: /usr/include/bits/string_fortified.h:29: undefined reference to `emul_memcpy'
/usr/bin/ld: /usr/include/bits/string_fortified.h:29: undefined reference to `emul_memcpy'
collect2: error: ld returned 1 exit status
make[5]: *** [Makefile:54: afl-harness] Error 1
make[4]: *** [/builddir/build/BUILD/xen-4.18.0/tools/fuzz/../../tools/Rules.mk:204: subdir-all-x86_instruction_emulator] Error 2

Reply via email to