File: bpf-stack-protector.c

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (34 lines) | stat: -rw-r--r-- 1,328 bytes parent folder | download | duplicates (10)
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
32
33
34
// REQUIRES: bpf-registered-target

// RUN: %clang -target bpf -S -emit-llvm -o - %s -fno-stack-protector 2>&1 \
// RUN:        | FileCheck -check-prefix=OFF -check-prefix=COMMON %s

// RUN: %clang -target bpf -S -emit-llvm -o - %s -fstack-protector 2>&1 \
// RUN:        | FileCheck -check-prefix=ON -check-prefix=COMMON -check-prefix=WARNING %s

// RUN: %clang -target bpf -S -emit-llvm -o - %s -fstack-protector-all 2>&1 \
// RUN:        | FileCheck -check-prefix=ALL -check-prefix=COMMON -check-prefix=WARNING %s

// RUN: %clang -target bpf -S -emit-llvm -o - %s -fstack-protector-strong 2>&1 \
// RUN:        | FileCheck -check-prefix=STRONG -check-prefix=COMMON -check-prefix=WARNING %s

typedef __SIZE_TYPE__ size_t;

int printf(const char * _Format, ...);
size_t strlen(const char *s);
char *strcpy(char *s1, const char *s2);

//     OFF-NOT: warning
//          ON: warning: ignoring '-fstack-protector'
//         ALL: warning: ignoring '-fstack-protector-all'
//      STRONG: warning: ignoring '-fstack-protector-strong'
// WARNING-SAME: option as it is not currently supported for target 'bpf'

// COMMON: define {{.*}}void @test1(ptr noundef %{{[0-9a-z]+}}) #[[A:.*]] {
void test1(const char *msg) {
  char a[strlen(msg) + 1];
  strcpy(a, msg);
  printf("%s\n", a);
}

// COMMON-NOT: attributes #[[A]] = {{.*}} ssp