diff mbox series

[pushed] testsuite, Darwin : Fix match output for asan/memcmp-1.c.

Message ID E2358BA2-A188-4CA2-876F-D2D562FBB1F4@sandoe.co.uk
State New
Headers show
Series [pushed] testsuite, Darwin : Fix match output for asan/memcmp-1.c. | expand

Commit Message

Iain Sandoe March 17, 2021, 7:16 p.m. UTC
Hi,

The Darwin part of libasan produces different output for memcmp
cases from other ports.  The GCC implementation does produce the
same output for this test as the clang one (modulo the two points
below).

1. To be more compatible with Linux, Darwin testcases that include
string.h should set _FORTIFY_SOURCE=0 since, otherwise, it will be
defaulted on and the _chk versions of the string builtins will be
used.

2. The system tool that handles symbolization (atos) is not reliable
with GCC's DWARF-2 output but, fortunately, all the platform
versions that support the current sanitizers are able to handle
dwarf-3 for this testcase.

tested on all the Darwin versions that currently support libsanitizer
(Darwin13..20) and on x86_64-linux-gnu,
pushed to master,
thanks
Iain

gcc/testsuite/ChangeLog:

	* c-c++-common/asan/memcmp-1.c: Add _FORTIFY_SOURCE=0 and
	-gdwarf-3 to the command line options.  Provide Darwin-
	specific match lines for the expected output.
---
 gcc/testsuite/c-c++-common/asan/memcmp-1.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/gcc/testsuite/c-c++-common/asan/memcmp-1.c b/gcc/testsuite/c-c++-common/asan/memcmp-1.c
index 0403ad78945..0d08c098e0e 100644
--- a/gcc/testsuite/c-c++-common/asan/memcmp-1.c
+++ b/gcc/testsuite/c-c++-common/asan/memcmp-1.c
@@ -1,5 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-options "-fno-builtin-memcmp" } */
+/* { dg-additional-options "-D_FORTIFY_SOURCE=0 -gdwarf-3" { target *-*-darwin* } } */
 /* { dg-shouldfail "asan" } */
 
 #include <string.h>
@@ -16,5 +17,8 @@  main ()
 }
 
 /* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow.*(\n|\r\n|\r)" } */
-/* { dg-output "    #\[1-9\] 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)memcmp|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "    #\[2-9\] 0x\[0-9a-f\]+ +(in _*main|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "    #\[1-9\] 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)memcmp|\[(\])\[^\n\r]*(\n|\r\n|\r)" { target { ! *-*-darwin* } } } */
+/* { dg-output "    #\[2-9\] 0x\[0-9a-f\]+ +(in _*main|\[(\])\[^\n\r]*(\n|\r\n|\r)" { target { ! *-*-darwin* } } } */
+
+/* { dg-output "    #\[0-9\] 0x\[0-9a-f\]+ +(in MemcmpInterceptorCommon|\[(\])\[^\n\r]*(\n|\r\n|\r)" { target *-*-darwin* } } */
+/* { dg-output "    #\[1-9\] 0x\[0-9a-f\]+ +(in wrap_(memcmp|bcmp)|\[(\])\[^\n\r]*(\n|\r\n|\r)" { target *-*-darwin* } } */