File: builtin-special-handling.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A12.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 959,712 kB
  • sloc: cpp: 3,275,382; ansic: 2,061,766; ada: 840,956; f90: 208,513; makefile: 76,132; asm: 73,433; xml: 50,448; exp: 34,146; sh: 32,436; objc: 15,637; fortran: 14,012; python: 11,991; pascal: 6,787; awk: 4,779; perl: 3,054; yacc: 338; ml: 285; lex: 201; haskell: 122
file content (31 lines) | stat: -rw-r--r-- 1,258 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* { dg-do compile } */
/* { dg-additional-options "-fdump-tree-asan" } */
/* { dg-skip-if "" { *-*-* }  { "-O0" } { "" } } */
/* Only skip the -flto tests without the -flto-partition=none.
   With -flto-partition=none we still get a asan1 dump file, without that
   parameter we only get the lto dump files (which means scan-tree-dump-times
   doesn't work.  */
/* { dg-skip-if "" { *-*-* }  { "-flto" } { "-flto-partition=none" } } */

typedef __SIZE_TYPE__ size_t;
/* Functions to observe that HWASAN instruments memory builtins in the expected
   manner.  */
void * __attribute__((noinline))
memset_builtin (void *dest, int value, size_t len)
{
  return __builtin_memset (dest, value, len);
}

/* HWASAN avoids strlen because it doesn't know the size of the memory access
   until *after* the function call.  */
size_t __attribute__ ((noinline))
strlen_builtin (char *element)
{
  return __builtin_strlen (element);
}

/* First test ensures that the HWASAN_CHECK was emitted before the
   memset.  Second test ensures there was only HWASAN_CHECK (which demonstrates
   that strlen was not instrumented).  */
/* { dg-final { scan-tree-dump-times "HWASAN_CHECK.*memset" 1 "asan1" } } */
/* { dg-final { scan-tree-dump-times "HWASAN_CHECK" 1 "asan1" } } */