1 // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=LLVM
2 // RUN: %clang_cc1 -triple x86_64-linux -S -o - %s | FileCheck %s --check-prefix=ASM
3 // Actually, any ELF target would do
4 // REQUIRES: x86-registered-target
5
6 #pragma clang section bss = "B$$" data = "d@t@" rodata = "r0d@t@"
7
8 const int a = 1;
f()9 const int *f() { return &a; }
10
11 int init();
12 const int b = init();
13
14 int c = 2;
15
16 int d = init();
17
18 int e;
19
20 // LLVM: @_ZL1a = internal constant i32 1, align 4 #[[#A:]]
21 // LLVM: @_ZL1b = internal global i32 0, align 4 #[[#A]]
22 // LLVM: @c = {{.*}}global i32 2, align 4 #[[#A]]
23 // LLVM: @d = {{.*}}global i32 0, align 4 #[[#A]]
24 // LLVM: @e = {{.*}}global i32 0, align 4 #[[#A]]
25
26 // LLVM: attributes #[[#A]] = { "bss-section"="B$$" "data-section"="d@t@" "rodata-section"="r0d@t@" }
27
28 // ASM: .section "r0d@t@","a",@progbits
29 // ASM-NOT: .section
30 // ASM-LABEL: _ZL1a:
31 // ASM-NEXT: .long 1
32
33 // ASM: .section "B$$","aw",@nobits
34 // ASM-NOT: .section
35 // ASM-LABEL: _ZL1b:
36 // ASM-NEXT: .long 0
37
38 // ASM: .section "d@t@","aw",@progbits
39 // ASM-NOT: .section
40 // ASM-LABEL: c:
41 // ASM: .long 2
42
43 // ASM: .section "B$$","aw",@nobits
44 // ASM-NOT: .section
45 // ASM-LABEL: d:
46 // ASM: .long 0
47
48 // ASM-NOT: .section
49 // ASM-LABEL: e:
50 // ASM .long 0
51