[gcc r10-9539] testsuite, Darwin : Fix the asan/strncpy-overflow-1 test.

Iain D Sandoe iains@gcc.gnu.org
Wed Mar 24 22:07:48 GMT 2021


https://gcc.gnu.org/g:716d345c237f030a3e85d7410b06a8c1ac4c46fb

commit r10-9539-g716d345c237f030a3e85d7410b06a8c1ac4c46fb
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Wed Mar 17 13:05:47 2021 +0000

    testsuite, Darwin : Fix the asan/strncpy-overflow-1 test.
    
    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.  This testcase fails otherwise because there's no convenient
    way to disable the _chk builtins.
    
    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.
    
    gcc/testsuite/ChangeLog:
    
            PR sanitizer/96318
            * c-c++-common/asan/strncpy-overflow-1.c: Add _FORTIFY_SOURCE=0 and
            -gdwarf-3 to the command line options. Adjust the expected line
            numbers for the revised options header.
    
    (cherry picked from commit c86c5195c8c02f5891a222f498c074b373aa946c)

Diff:
---
 gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c b/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
index a9c9b182888..3d439160b7e 100644
--- a/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
+++ b/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-fno-builtin-malloc -fno-builtin-strncpy" } */
+/* { dg-additional-options "-D_FORTIFY_SOURCE=0 -gdwarf-3" { target *-*-darwin* } } */
 /* { dg-shouldfail "asan" } */
 
 #include <string.h>
@@ -14,8 +15,8 @@ int main(int argc, char **argv) {
 
 /* { dg-output "WRITE of size \[0-9\]* at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #0 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)strncpy|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "    #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*strncpy-overflow-1.c:11|\[^\n\r]*:0|\[^\n\r]*\\+0x\[0-9a-z\]*)|\[(\]).*(\n|\r\n|\r)" } */
+/* { dg-output "    #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*strncpy-overflow-1.c:12|\[^\n\r]*:0|\[^\n\r]*\\+0x\[0-9a-z\]*)|\[(\]).*(\n|\r\n|\r)" } */
 /* { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 0 bytes to the right of 9-byte region\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "\[^\n\r]*allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #0 0x\[0-9a-f\]+ +(in _*(interceptor_|wrap_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "    #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*strncpy-overflow-1.c:10|\[^\n\r]*:0|\[^\n\r]*\\+0x\[0-9a-z\]*)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "    #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*strncpy-overflow-1.c:11|\[^\n\r]*:0|\[^\n\r]*\\+0x\[0-9a-z\]*)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */


More information about the Gcc-cvs mailing list