| 1 |
// Test the scan-symbol-section directive. |
| 2 |
|
| 3 |
// { dg-do preprocess } |
| 4 |
|
| 5 |
// The .section directive changes the section for all following symbols. |
| 6 |
.section .text |
| 7 |
// { dg-final { scan-symbol-section "dg-scan-symbol-section-exp-P.i" {^_test_function_1$} {^\.text$} } } |
| 8 |
_test_function_1: |
| 9 |
// { dg-final { scan-symbol-section "dg-scan-symbol-section-exp-P.i" {^_test_function_2$} {^\.text$} } } |
| 10 |
_test_function_2: |
| 11 |
|
| 12 |
// For ELF targets, the .section directive can take multiple arguments. |
| 13 |
.section .other_text_section,"ax",progbits |
| 14 |
// { dg-final { scan-symbol-section "dg-scan-symbol-section-exp-P.i" {^_test_elf_function$} {^\.other_text_section$} } } |
| 15 |
_test_elf_function: |
| 16 |
|
| 17 |
// For Mach-O targets, the .section directive takes a segment name and a section name. |
| 18 |
.section __TEXT,__my_text_section |
| 19 |
// { dg-final { scan-symbol-section "dg-scan-symbol-section-exp-P.i" {^_test_macho_function$} {^__TEXT,__my_text_section$} } } |
| 20 |
_test_macho_function: |
| 21 |
// Extra whitespace between .section arguments should be ignored. |
| 22 |
.section __DATA , __testsection |
| 23 |
// { dg-final { scan-symbol-section "dg-scan-symbol-section-exp-P.i" {^_test_macho_var$} {^__DATA,__testsection$} } } |
| 24 |
_test_macho_var: |
| 25 |
|
| 26 |
// The .data directive sets the section for all following symbols to '.data'. |
| 27 |
// { dg-final { scan-symbol-section "dg-scan-symbol-section-exp-P.i" {^_test_var_1$} {^\.data$} } } |
| 28 |
.data |
| 29 |
_test_var_1: |
| 30 |
|
| 31 |
// The .text directive sets the section for all following symbols to '.text'. |
| 32 |
// { dg-final { scan-symbol-section "dg-scan-symbol-section-exp-P.i" {^_test_function_3$} {^\.text$} } } |
| 33 |
.text |
| 34 |
_test_function_3: |
| 35 |
|
| 36 |
// The .const directive sets the section for all following symbols to '.const'. |
| 37 |
// { dg-final { scan-symbol-section "dg-scan-symbol-section-exp-P.i" {^_test_data_1$} {^\.const$} } } |
| 38 |
.const |
| 39 |
_test_data_1: |
| 40 |
|
| 41 |
// Other directives do not affect the section of following symbols. |
| 42 |
// { dg-final { scan-symbol-section "dg-scan-symbol-section-exp-P.i" {^_test_var_2$} {^\.data$} } } |
| 43 |
.data |
| 44 |
.p2align 2 |
| 45 |
.size _test_var_2, 4 |
| 46 |
_test_var_2: |
| 47 |
|
| 48 |
// Symbol name patterns can match multiple symbols, and section name patterns |
| 49 |
// can match multiple sections. |
| 50 |
// { dg-final { scan-symbol-section "dg-scan-symbol-section-exp-P.i" {^_test_function_} {^(\.|__TEXT,).*text} } } |