With _FORTIFY_SOURCE >= 2 (enabled by -fhardened), vfprintf-chk-1.c's
__vfprintf_chk ends up calling __vprintf_chk rather than vprintf.
```
--- a/fortify.s
+++ b/no-fortify.s
@@ -8,27 +8,28 @@
[...]
__vfprintf_chk:
[...]
movl $1, should_optimize(%rip)
- jmp __vfprintf_chk
+ jmp vfprintf@PLT
```
2024-02-15 Sam James <[email protected]>
gcc/testsuite/ChangeLog:
* gcc.c-torture/execute/vfprintf-chk-1.c (__vfprintf_chk): Undefine
_FORTIFY_SOURCE
to call the real vfprintf.
---
The test, AIUI, is trying to test GCC's own basic _chk bits rather than
any of e.g. glibc's _FORTIFY_SOURCE handling.
I'm curious as to why only vfprintf triggers this right now. If this patch is
right,
perhaps we should do printf-chk-1.c, fprintf-chk-1.c, and vprintf-chk-1.
Please push if OK as I don't have access.
gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.c
b/gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.c
index 401eaf4304a4..a8e5689e3fe6 100644
--- a/gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.c
@@ -1,6 +1,7 @@
/* { dg-skip-if "requires io" { freestanding } } */
#ifndef test
+#undef _FORTIFY_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
--
2.43.1