From 0b34dbc0a24864b1674bff7a92fa3cf0f1cbcea1 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 4 Feb 2021 23:42:09 +0100 Subject: [PATCH] testsuite: Fix up pr25376.c on powerpc64-linux and array-quals-1.c on powerpc-linux [PR98325] The following patch fixes the pr25376.c testcase on powerpc64-linux and array-quals-1.c on powerpc-linux. Previously it failed like: FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?a1\$ (found a1) has section ^\\\\.(const|rodata|srodata)|\\\\[RO\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?b1\$ (found b1) has section ^\\\\.(const|rodata|srodata)|\\\\[RO\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?c1\$ (found c1) has section ^\\\\.(const|rodata|srodata)|\\\\[RO\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?d1\$ (found d1) has section ^\\\\.(const|rodata|srodata)|\\\\[RO\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?p\$ (found p) has section ^\\\\.(const|rodata|srodata)|\\\\[RW\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?p1\$ (found p1) has section ^\\\\.(const|rodata|srodata)|\\\\[RW\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?q\$ (found q) has section ^\\\\.(const|rodata|srodata)|\\\\[RW\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?q1\$ (found q1) has section ^\\\\.(const|rodata|srodata)|\\\\[RW\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?r\$ (found r) has section ^\\\\.(const|rodata|srodata)|\\\\[RW\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?r1\$ (found r1) has section ^\\\\.(const|rodata|srodata)|\\\\[RW\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?s\$ (found s) has section ^\\\\.(const|rodata|srodata)|\\\\[RW\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?s1\$ (found s1) has section ^\\\\.(const|rodata|srodata)|\\\\[RW\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?t\$ (found t) has section ^\\\\.(const|rodata|srodata)|\\\\[RW\\\\] (found .sdata) FAIL: gcc.dg/array-quals-1.c scan-assembler-symbol-section symbol ^_?t1\$ (found t1) has section ^\\\\.(const|rodata|srodata)|\\\\[RW\\\\] (found .sdata) FAIL: gcc.dg/pr25376.c scan-assembler-symbol-section symbol simple\$ (found .L.simple) has section ^\\\\.?my_named_section|simple\\\\[DS\\\\]|^\\\\"\\\\.opd\\\\" (found .opd) FAIL: gcc.dg/pr25376.c scan-assembler-symbol-section symbol simple\$ (found simple) has section ^\\\\.?my_named_section|simple\\\\[DS\\\\]|^\\\\"\\\\.opd\\\\" (found .opd) The problem with pr25376.c testcase are the ELFv1 function descriptors, .section my_named_section,"ax",@progbits .align 2 .globl simple .section ".opd","aw" .align 3 simple: .quad .L.simple,.TOC.@tocbase,0 .previous .type simple, @function .L.simple: so the simple symbol is found in the .opd section rather than in the my_named_section the test attempts to verify for that symbol. This patch deals it with two changes, the last two hunks in scanasm.exp teach it about the behavior of .previous directive and the first hunk for powerpc if symbol is in .opd section will try section in which the .L.symbol label is instead. The array-quals-1.c test fails because on powerpc-linux the symbols are emitted into .sdata section rather than one of the expected ones. 2021-02-04 Jakub Jelinek PR testsuite/98325 * lib/scanasm.exp (dg-scan-symbol-section): For powerpc*-*-* targets if $section is .opd, look at .L.$symbol_name's section. (parse_section_section_of_symbols): Handle .previous directive. * gcc.dg/array-quals-1.c: Allow .sdata section. --- gcc/testsuite/gcc.dg/array-quals-1.c | 30 ++++++++++++++-------------- gcc/testsuite/lib/scanasm.exp | 12 ++++++++++- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/gcc/testsuite/gcc.dg/array-quals-1.c b/gcc/testsuite/gcc.dg/array-quals-1.c index c8d36296434..5d9170ea81e 100644 --- a/gcc/testsuite/gcc.dg/array-quals-1.c +++ b/gcc/testsuite/gcc.dg/array-quals-1.c @@ -8,44 +8,44 @@ /* { dg-final { scan-assembler-not "\\.data(?!\\.rel\\.ro)" { xfail powerpc*-*-aix* mmix-*-* x86_64-*-mingw* } } } */ /* { dg-final { scan-assembler-symbol-section {^_?a$} {^\.(const|rodata|srodata)|\[RO\]} } } */ static const int a[2] = { 1, 2 }; -/* { dg-final { scan-assembler-symbol-section {^_?a1$} {^\.(const|rodata|srodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?a1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ const int a1[2] = { 1, 2 }; typedef const int ci; /* { dg-final { scan-assembler-symbol-section {^_?b$} {^\.(const|rodata|srodata)|\[RO\]} } } */ static ci b[2] = { 3, 4 }; -/* { dg-final { scan-assembler-symbol-section {^_?b1$} {^\.(const|rodata|srodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?b1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ ci b1[2] = { 3, 4 }; typedef int ia[2]; /* { dg-final { scan-assembler-symbol-section {^_?c$} {^\.(const|rodata|srodata)|\[RO\]} } } */ static const ia c = { 5, 6 }; -/* { dg-final { scan-assembler-symbol-section {^_?c1$} {^\.(const|rodata|srodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?c1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ const ia c1 = { 5, 6 }; typedef const int cia[2]; /* { dg-final { scan-assembler-symbol-section {^_?d$} {^\.(const|rodata|srodata)|\[RO\]} } } */ static cia d = { 7, 8 }; -/* { dg-final { scan-assembler-symbol-section {^_?d1$} {^\.(const|rodata|srodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?d1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ cia d1 = { 7, 8 }; /* { dg-final { scan-assembler-symbol-section {^_?e$} {^\.(const|rodata|srodata)|\[RO\]} } } */ static cia e[2] = { { 1, 2 }, { 3, 4 } }; -/* { dg-final { scan-assembler-symbol-section {^_?e1$} {^\.(const|rodata|srodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?e1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ cia e1[2] = { { 1, 2 }, { 3, 4 } }; -/* { dg-final { scan-assembler-symbol-section {^_?p$} {^\.(const|rodata|srodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?p$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ void *const p = &a; -/* { dg-final { scan-assembler-symbol-section {^_?q$} {^\.(const|rodata|srodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?q$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ void *const q = &b; -/* { dg-final { scan-assembler-symbol-section {^_?r$} {^\.(const|rodata|srodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?r$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ void *const r = &c; -/* { dg-final { scan-assembler-symbol-section {^_?s$} {^\.(const|rodata|srodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?s$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ void *const s = &d; -/* { dg-final { scan-assembler-symbol-section {^_?t$} {^\.(const|rodata|srodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?t$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ void *const t = &e; -/* { dg-final { scan-assembler-symbol-section {^_?p1$} {^\.(const|rodata|srodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?p1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ void *const p1 = &a1; -/* { dg-final { scan-assembler-symbol-section {^_?q1$} {^\.(const|rodata|srodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?q1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ void *const q1 = &b1; -/* { dg-final { scan-assembler-symbol-section {^_?r1$} {^\.(const|rodata|srodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?r1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ void *const r1 = &c1; -/* { dg-final { scan-assembler-symbol-section {^_?s1$} {^\.(const|rodata|srodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?s1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ void *const s1 = &d1; -/* { dg-final { scan-assembler-symbol-section {^_?t1$} {^\.(const|rodata|srodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?t1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ void *const t1 = &e1; diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp index 65e311825a6..e7236087a75 100644 --- a/gcc/testsuite/lib/scanasm.exp +++ b/gcc/testsuite/lib/scanasm.exp @@ -275,6 +275,9 @@ proc dg-scan-symbol-section { name testcase output_file orig_args } { foreach symbol_name [lsort [array names section_by_symbol]] { if { [regexp -- $symbol_pattern $symbol_name] } { set section $section_by_symbol($symbol_name) + if { [istarget powerpc*-*-*] && $section == ".opd" } { + set section $section_by_symbol(.L.$symbol_name) + } set description "$testcase $name symbol $printable_symbol_pattern (found $symbol_name) has section $printable_expected_section_pattern" if { $section == "" } { fail "$description (no section detected)" @@ -321,13 +324,16 @@ proc parse_section_of_symbols { filename result } { set section_pattern {^\s*(?:(?:\.section|\.csect)\s+(.*)|(\.const|\.data|\.text)\s*)$} set label_pattern {^(\S+):$} + set previous_pattern {^\s*\.previous\s*$} set fd [open $filename r] set current_section "" + set prev_section "" while { [gets $fd line] >= 0 } { if { [regexp -- $label_pattern $line dummy symbol_name] } { set up_result($symbol_name) $current_section } elseif { [regexp -- $section_pattern $line dummy section_directive_arguments full_section_directive] } { + set prev_section $current_section if { $full_section_directive eq "" } { # Example: .section .text,"ax",progbits # Example: .section ".text",#alloc,#execinstr,#progbits @@ -344,7 +350,11 @@ proc parse_section_of_symbols { filename result } { # Example: .text set current_section "$full_section_directive" } - } + } elseif { [regexp -- $previous_pattern $line dummy] } { + set sect $prev_section + set prev_section $current_section + set current_section $sect + } } close $fd } -- 2.30.2