aboutsummaryrefslogtreecommitdiffstats
path: root/test/MC/ELF/section.s
blob: c71e1a72c4710c21b9ad44d9a35ffda3262752bf (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump  | FileCheck %s

// Test that these names are accepted.

.section	.note.GNU-stack,"",@progbits
.section	.note.GNU-stack2,"",%progbits
.section	.note.GNU-,"",@progbits
.section	-.note.GNU,"",@progbits

// CHECK: ('sh_name', 0x00000038) # '.note.GNU-stack'
// CHECK: ('sh_name', 0x0000008f) # '.note.GNU-stack2'
// CHECK: ('sh_name', 0x000000a0) # '.note.GNU-'
// CHECK: ('sh_name', 0x00000084) # '-.note.GNU'

// Test that the defaults are used

.section	.init
.section	.fini
.section	.rodata
.section	zed, ""

// CHECK:      (('sh_name', 0x00000012) # '.init'
// CHECK-NEXT:  ('sh_type', 0x00000001)
// CHECK-NEXT:  ('sh_flags', 0x0000000000000006)
// CHECK-NEXT:  ('sh_addr', 0x0000000000000000)
// CHECK-NEXT:  ('sh_offset', 0x0000000000000050)
// CHECK-NEXT:  ('sh_size', 0x0000000000000000)
// CHECK-NEXT:  ('sh_link', 0x00000000)
// CHECK-NEXT:  ('sh_info', 0x00000000)
// CHECK-NEXT:  ('sh_addralign', 0x0000000000000001)
// CHECK-NEXT:  ('sh_entsize', 0x0000000000000000)
// CHECK-NEXT: ),
// CHECK-NEXT: # Section 11
// CHECK-NEXT: (('sh_name', 0x00000048) # '.fini'
// CHECK-NEXT:  ('sh_type', 0x00000001)
// CHECK-NEXT:  ('sh_flags', 0x0000000000000006)
// CHECK-NEXT:  ('sh_addr', 0x0000000000000000)
// CHECK-NEXT:  ('sh_offset', 0x0000000000000050)
// CHECK-NEXT:  ('sh_size', 0x0000000000000000)
// CHECK-NEXT:  ('sh_link', 0x00000000)
// CHECK-NEXT:  ('sh_info', 0x00000000)
// CHECK-NEXT:  ('sh_addralign', 0x0000000000000001)
// CHECK-NEXT:  ('sh_entsize', 0x0000000000000000)
// CHECK-NEXT: ),
// CHECK-NEXT: # Section 12
// CHECK-NEXT: (('sh_name', 0x00000076) # '.rodata'
// CHECK-NEXT:  ('sh_type', 0x00000001)
// CHECK-NEXT:  ('sh_flags', 0x0000000000000002)
// CHECK-NEXT:  ('sh_addr', 0x0000000000000000)
// CHECK-NEXT:  ('sh_offset', 0x0000000000000050)
// CHECK-NEXT:  ('sh_size', 0x0000000000000000)
// CHECK-NEXT:  ('sh_link', 0x00000000)
// CHECK-NEXT:  ('sh_info', 0x00000000)
// CHECK-NEXT:  ('sh_addralign', 0x0000000000000001)
// CHECK-NEXT:  ('sh_entsize', 0x0000000000000000)
// CHECK-NEXT: ),
// CHECK-NEXT: # Section 13
// CHECK-NEXT: (('sh_name', 0x00000058) # 'zed'
// CHECK-NEXT:  ('sh_type', 0x00000001)
// CHECK-NEXT:  ('sh_flags', 0x0000000000000000)
// CHECK-NEXT:  ('sh_addr', 0x0000000000000000)
// CHECK-NEXT:  ('sh_offset', 0x0000000000000050)
// CHECK-NEXT:  ('sh_size', 0x0000000000000000)
// CHECK-NEXT:  ('sh_link', 0x00000000)
// CHECK-NEXT:  ('sh_info', 0x00000000)
// CHECK-NEXT:  ('sh_addralign', 0x0000000000000001)
// CHECK-NEXT:  ('sh_entsize', 0x0000000000000000)
// CHECK-NEXT: ),

.section	.note.test,"",@note
// CHECK:       (('sh_name', 0x00000007) # '.note.test'
// CHECK-NEXT:   ('sh_type', 0x00000007)
// CHECK-NEXT:   ('sh_flags', 0x0000000000000000)
// CHECK-NEXT:   ('sh_addr', 0x0000000000000000)
// CHECK-NEXT:   ('sh_offset', 0x0000000000000050)
// CHECK-NEXT:   ('sh_size', 0x0000000000000000)
// CHECK-NEXT:   ('sh_link', 0x00000000)
// CHECK-NEXT:   ('sh_info', 0x00000000)
// CHECK-NEXT:   ('sh_addralign', 0x0000000000000001)
// CHECK-NEXT:   ('sh_entsize', 0x0000000000000000)
// CHECK-NEXT:  ),

// Test that we can parse these
foo:
bar:
.section        .text.foo,"axG",@progbits,foo,comdat
.section        .text.bar,"axMG",@progbits,42,bar,comdat

// Test that the default values are not used

.section .eh_frame,"a",@unwind

// CHECK:       (('sh_name', 0x0000004e) # '.eh_frame'
// CHECK-NEXT:   ('sh_type', 0x70000001)
// CHECK-NEXT:   ('sh_flags', 0x0000000000000002)
// CHECK-NEXT:   ('sh_addr', 0x0000000000000000)
// CHECK-NEXT:   ('sh_offset', 0x0000000000000050)
// CHECK-NEXT:   ('sh_size', 0x0000000000000000)
// CHECK-NEXT:   ('sh_link', 0x00000000)
// CHECK-NEXT:   ('sh_info', 0x00000000)
// CHECK-NEXT:   ('sh_addralign', 0x0000000000000001)
// CHECK-NEXT:   ('sh_entsize', 0x0000000000000000)
// CHECK-NEXT:  ),

// Test that we handle the strings like gas
.section bar-"foo"
.section "foo"

// CHECK: ('sh_name', 0x000000ab) # 'bar-"foo"'
// CHECK: ('sh_name', 0x00000034) # 'foo'