1// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -S - | FileCheck %s 2// RUN: llvm-mc -filetype=asm -triple x86_64-pc-linux-gnu %s -o - | FileCheck %s --check-prefix=ASM 3 4// Test that these names are accepted. 5 6.section .note.GNU-stack,"",@progbits 7.section .note.GNU-stack2,"",%progbits 8.section .note.GNU-,"",@progbits 9.section -.note.GNU,"","progbits" 10.section src/stack.c,"",@progbits 11.section ~!@$%^&*()_-+={[}]|\\:<>,"",@progbits 12 13// CHECK: Name: .note.GNU-stack 14// CHECK: Name: .note.GNU-stack2 15// CHECK: Name: .note.GNU- 16// CHECK: Name: -.note.GNU 17// CHECK: Name: src/stack.c 18// CHECK: Name: ~!@$%^&*()_-+={[}]|\\:<> 19 20// Test that the defaults are used 21 22.section .init 23.section .fini 24.section .rodata 25.section zed, "" 26 27// CHECK: Section { 28// CHECK: Name: .init 29// CHECK-NEXT: Type: SHT_PROGBITS 30// CHECK-NEXT: Flags [ 31// CHECK-NEXT: SHF_ALLOC 32// CHECK-NEXT: SHF_EXECINSTR 33// CHECK-NEXT: ] 34// CHECK-NEXT: Address: 0x0 35// CHECK-NEXT: Offset: 36// CHECK-NEXT: Size: 0 37// CHECK-NEXT: Link: 0 38// CHECK-NEXT: Info: 0 39// CHECK-NEXT: AddressAlignment: 1 40// CHECK-NEXT: EntrySize: 0 41// CHECK-NEXT: } 42// CHECK-NEXT: Section { 43// CHECK-NEXT: Index: 44// CHECK-NEXT: Name: .fini 45// CHECK-NEXT: Type: SHT_PROGBITS 46// CHECK-NEXT: Flags [ 47// CHECK-NEXT: SHF_ALLOC 48// CHECK-NEXT: SHF_EXECINSTR 49// CHECK-NEXT: ] 50// CHECK-NEXT: Address: 0x0 51// CHECK-NEXT: Offset: 52// CHECK-NEXT: Size: 0 53// CHECK-NEXT: Link: 0 54// CHECK-NEXT: Info: 0 55// CHECK-NEXT: AddressAlignment: 1 56// CHECK-NEXT: EntrySize: 0 57// CHECK-NEXT: } 58// CHECK-NEXT: Section { 59// CHECK-NEXT: Index: 60// CHECK-NEXT: Name: .rodata 61// CHECK-NEXT: Type: SHT_PROGBITS 62// CHECK-NEXT: Flags [ 63// CHECK-NEXT: SHF_ALLOC 64// CHECK-NEXT: ] 65// CHECK-NEXT: Address: 0x0 66// CHECK-NEXT: Offset: 67// CHECK-NEXT: Size: 0 68// CHECK-NEXT: Link: 0 69// CHECK-NEXT: Info: 0 70// CHECK-NEXT: AddressAlignment: 1 71// CHECK-NEXT: EntrySize: 0 72// CHECK-NEXT: } 73// CHECK-NEXT: Section { 74// CHECK-NEXT: Index: 75// CHECK-NEXT: Name: zed 76// CHECK-NEXT: Type: SHT_PROGBITS 77// CHECK-NEXT: Flags [ 78// CHECK-NEXT: ] 79// CHECK-NEXT: Address: 0x0 80// CHECK-NEXT: Offset: 81// CHECK-NEXT: Size: 0 82// CHECK-NEXT: Link: 0 83// CHECK-NEXT: Info: 0 84// CHECK-NEXT: AddressAlignment: 1 85// CHECK-NEXT: EntrySize: 0 86// CHECK-NEXT: } 87 88.section .note.test,"",@note 89// CHECK: Section { 90// CHECK: Name: .note.test 91// CHECK-NEXT: Type: SHT_NOTE 92// CHECK-NEXT: Flags [ 93// CHECK-NEXT: ] 94// CHECK-NEXT: Address: 0x0 95// CHECK-NEXT: Offset: 96// CHECK-NEXT: Size: 0 97// CHECK-NEXT: Link: 0 98// CHECK-NEXT: Info: 0 99// CHECK-NEXT: AddressAlignment: 1 100// CHECK-NEXT: EntrySize: 0 101// CHECK-NEXT: } 102 103// Test that we can parse these 104foo: 105bar: 106.section .text.foo,"axG",@progbits,foo,comdat 107.section .text.bar,"axMG",@progbits,42,bar,comdat 108 109// Test that the default values are not used 110 111.section .eh_frame,"a",@unwind 112 113// CHECK: Section { 114// CHECK: Name: .eh_frame 115// CHECK-NEXT: Type: SHT_X86_64_UNWIND 116// CHECK-NEXT: Flags [ 117// CHECK-NEXT: SHF_ALLOC 118// CHECK-NEXT: ] 119// CHECK-NEXT: Address: 0x0 120// CHECK-NEXT: Offset: 121// CHECK-NEXT: Size: 0 122// CHECK-NEXT: Link: 0 123// CHECK-NEXT: Info: 0 124// CHECK-NEXT: AddressAlignment: 1 125// CHECK-NEXT: EntrySize: 0 126// CHECK-NEXT: } 127 128.section .excluded,"e",@progbits 129 130// CHECK: Section { 131// CHECK: Name: .excluded 132// CHECK-NEXT: Type: SHT_PROGBITS (0x1) 133// CHECK-NEXT: Flags [ (0x80000000) 134// CHECK-NEXT: SHF_EXCLUDE (0x80000000) 135// CHECK-NEXT: ] 136// CHECK-NEXT: Address: 0x0 137// CHECK-NEXT: Offset: 138// CHECK-NEXT: Size: 0 139// CHECK-NEXT: Link: 0 140// CHECK-NEXT: Info: 0 141// CHECK-NEXT: AddressAlignment: 1 142// CHECK-NEXT: EntrySize: 0 143// CHECK-NEXT: } 144 145// Test that we handle the strings like gas 146.section bar-"foo" 147.section "fooo" 148 149 150// CHECK: Section { 151// CHECK: Name: bar-"foo" 152// CHECK: Section { 153// CHECK: Name: fooo 154 155// Test SHF_LINK_ORDER 156 157.section .shf_metadata_target1, "a" 158 .quad 0 159.section .shf_metadata_target2, "a", @progbits, unique, 1 160.Lshf_metadata_target2_1: 161 .quad 0 162.section .shf_metadata_target2, "a", @progbits, unique, 2 163.Lshf_metadata_target2_2: 164 .quad 0 165 166.section .shf_metadata1,"ao",@progbits,.Lshf_metadata_target2_1 167.section .shf_metadata2,"ao",@progbits,.Lshf_metadata_target2_2 168.section .shf_metadata3,"ao",@progbits,.shf_metadata_target1 169// ASM: .section .shf_metadata1,"ao",@progbits,.Lshf_metadata_target2_1 170// ASM: .section .shf_metadata2,"ao",@progbits,.Lshf_metadata_target2_2 171// ASM: .section .shf_metadata3,"ao",@progbits,.shf_metadata_target1 172 173// CHECK: Section { 174// CHECK: Index: 22 175// CHECK-NEXT: Name: .shf_metadata_target1 176 177// CHECK: Section { 178// CHECK: Index: 23 179// CHECK-NEXT: Name: .shf_metadata_target2 180 181// CHECK: Section { 182// CHECK: Index: 24 183// CHECK-NEXT: Name: .shf_metadata_target2 184 185// CHECK: Section { 186// CHECK: Name: .shf_metadata1 187// CHECK-NEXT: Type: SHT_PROGBITS 188// CHECK-NEXT: Flags [ 189// CHECK-NEXT: SHF_ALLOC 190// CHECK-NEXT: SHF_LINK_ORDER 191// CHECK-NEXT: ] 192// CHECK-NEXT: Address: 193// CHECK-NEXT: Offset: 194// CHECK-NEXT: Size: 195// CHECK-NEXT: Link: 23 196// CHECK-NEXT: Info: 0 197 198// CHECK: Section { 199// CHECK: Name: .shf_metadata2 200// CHECK-NEXT: Type: SHT_PROGBITS 201// CHECK-NEXT: Flags [ 202// CHECK-NEXT: SHF_ALLOC 203// CHECK-NEXT: SHF_LINK_ORDER 204// CHECK-NEXT: ] 205// CHECK-NEXT: Address: 206// CHECK-NEXT: Offset: 207// CHECK-NEXT: Size: 208// CHECK-NEXT: Link: 24 209// CHECK-NEXT: Info: 0 210 211// CHECK: Section { 212// CHECK: Name: .shf_metadata3 213// CHECK-NEXT: Type: SHT_PROGBITS 214// CHECK-NEXT: Flags [ 215// CHECK-NEXT: SHF_ALLOC 216// CHECK-NEXT: SHF_LINK_ORDER 217// CHECK-NEXT: ] 218// CHECK-NEXT: Address: 219// CHECK-NEXT: Offset: 220// CHECK-NEXT: Size: 221// CHECK-NEXT: Link: 22 222// CHECK-NEXT: Info: 0 223 224.section .text.foo 225// CHECK: Section { 226// CHECK: Name: .text.foo 227// CHECK-NEXT: Type: SHT_PROGBITS 228// CHECK-NEXT: Flags [ 229// CHECK-NEXT: SHF_ALLOC 230// CHECK-NEXT: SHF_EXECINSTR 231// CHECK-NEXT: ] 232 233.section .bss 234// CHECK: Section { 235// CHECK: Name: .bss 236// CHECK-NEXT: Type: SHT_NOBITS 237// CHECK-NEXT: Flags [ 238// CHECK-NEXT: SHF_ALLOC 239// CHECK-NEXT: SHF_WRITE 240// CHECK-NEXT: ] 241 242.section .bss.foo 243// CHECK: Section { 244// CHECK: Name: .bss.foo 245// CHECK-NEXT: Type: SHT_NOBITS 246// CHECK-NEXT: Flags [ 247// CHECK-NEXT: SHF_ALLOC 248// CHECK-NEXT: SHF_WRITE 249// CHECK-NEXT: ] 250 251.section .tbss 252// CHECK: Section { 253// CHECK: Name: .tbss 254// CHECK-NEXT: Type: SHT_NOBITS 255// CHECK-NEXT: Flags [ 256// CHECK-NEXT: SHF_ALLOC 257// CHECK-NEXT: SHF_TLS 258// CHECK-NEXT: SHF_WRITE 259// CHECK-NEXT: ] 260 261.section .tbss.foo 262// CHECK: Section { 263// CHECK: Name: .tbss.foo 264// CHECK-NEXT: Type: SHT_NOBITS 265// CHECK-NEXT: Flags [ 266// CHECK-NEXT: SHF_ALLOC 267// CHECK-NEXT: SHF_TLS 268// CHECK-NEXT: SHF_WRITE 269// CHECK-NEXT: ] 270 271// Test SHT_LLVM_ODRTAB 272 273.section .odrtab,"e",@llvm_odrtab 274// ASM: .section .odrtab,"e",@llvm_odrtab 275 276// CHECK: Section { 277// CHECK: Name: .odrtab 278// CHECK-NEXT: Type: SHT_LLVM_ODRTAB 279// CHECK-NEXT: Flags [ 280// CHECK-NEXT: SHF_EXCLUDE 281// CHECK-NEXT: ] 282 283// Test SHT_LLVM_LINKER_OPTIONS 284 285.section ".linker-options","e",@llvm_linker_options 286// ASM: .section ".linker-options","e",@llvm_linker_options 287 288// CHECK: Section { 289// CHECK: Name: .linker-options 290// CHECK-NEXT: Type: SHT_LLVM_LINKER_OPTIONS 291// CHECK-NEXT: Flags [ 292// CHECK-NEXT: SHF_EXCLUDE 293// CHECK-NEXT: ] 294// CHECK: } 295 296// Test SHT_LLVM_DEPENDENT_LIBRARIES 297 298.section .deplibs,"MS",@llvm_dependent_libraries,1 299// ASM: .section .deplibs,"MS",@llvm_dependent_libraries,1 300 301// CHECK: Section { 302// CHECK: Name: .deplibs 303// CHECK-NEXT: Type: SHT_LLVM_DEPENDENT_LIBRARIES 304// CHECK-NEXT: Flags [ 305// CHECK-NEXT: SHF_MERGE 306// CHECK-NEXT: SHF_STRINGS 307// CHECK-NEXT: ] 308// CHECK: } 309 310// Test SHT_LLVM_SYMPART 311 312.section .llvm_sympart,"",@llvm_sympart 313// ASM: .section .llvm_sympart,"",@llvm_sympart 314 315// CHECK: Section { 316// CHECK: Name: .llvm_sympart 317// CHECK-NEXT: Type: SHT_LLVM_SYMPART 318// CHECK-NEXT: Flags [ 319// CHECK-NEXT: ] 320// CHECK: } 321