aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>2020-12-13 12:48:26 +0100
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>2020-12-13 12:48:26 +0100
commitf1eeabc1fd0fff5b77db8672ff0c630bf891f40a (patch)
tree75fb99268459b0f284067ae3cfc0a97d449f8781 /gcc/testsuite
parent1498b1a8fb82834a8578a2a9a3525f38c3483d1e (diff)
downloadgcc-f1eeabc1fd0fff5b77db8672ff0c630bf891f40a.zip
gcc-f1eeabc1fd0fff5b77db8672ff0c630bf891f40a.tar.gz
gcc-f1eeabc1fd0fff5b77db8672ff0c630bf891f40a.tar.bz2
testsuite: Fix various scan-assembler-symbol-section issues
This patch addresses some of the issues that I found when looking into the failures of the scan-assembler-symbol-section tests on Solaris/SPARC. * The first issue was that on Solaris/SPARC, section names are double-quoted, both with as and gas: .section ".text" When using as, the section flag and type syntax is completely different from other ELF targets: .section "my_named_section",#alloc,#execinstr,#progbits This patch fixes this by stripping double quotes from section names. * However, this didn't work initially (only the leading quote was stripped), which is due to David's recent AIX patch: with the introduction of the new capturing group to handle both .section (ELF) and .csect (XCOFF), $full_section_directive would never be empty on ELF and Mach-O targets, so the extraction of the section name didn't work any longer. This had also broken the Darwin tests completely. * With working double quote stripping, all but one of the tests PASSed on Solaris/SPARC, the exception being: FAIL: gcc.dg/20021029-1.c scan-assembler-symbol-section symbol ar (found __sparc_get_pc_thunk.l7) has section ^\\\\.(const|rodata)|\\\\[RO\\\\] (found .text.__sparc_get_pc_thunk.l7%__sparc_get_pc_thunk.l7) This is due to the symbol name (ar) not being anchored in the test and unexpectedly matchting __sparc_get_pc_thunk.l7. * Next, I ran the tests on Darwin 11 and found two failing tests: FAIL: gcc.dg/darwin-sections.c scan-assembler-symbol-section symbol ^_a\$ (symbol not found) has section \\\\.data FAIL: gcc.dg/darwin-sections.c scan-assembler-symbol-section symbol ^_b\$ (symbol not found) has section \\\\.data is due to Iain's recent "Darwin : Begin rework of zero-fill sections." patch which emits .globl _a .zerofill __DATA,__common,_a,1,0 This is already scanned for, so the two scans above can just go. The other failing test is FAIL: g++.dg/gomp/tls-5.C -std=c++14 scan-assembler-symbol-section symbol ^_?_ZGR2ir_\$ (symbol not found) has section ^\\\\.tdata|\\\\[TL\\\\] FAIL: g++.dg/gomp/tls-5.C -std=c++14 scan-assembler-symbol-section symbol ^_?ir\$ (symbol not found) has section ^\\\\.tbss|\\\\[TL\\\\] Other scans are guarded by target tls_native, and indeed the assembler output has ___emutls_v._ZGR2ir_: ___emutls_t._ZGR2ir_: ___emutls_v.ir: Unfortunately scan-assembler-symbol-section doesn't support selects yet, which this test implements both for the benefit of this test and for symmetry. With those changes, test results are clean now on sparc-sun-solaris2.11, i386-pc-solaris2.11, i386-apple-darwin11.4.2, and powerpc-ibm-aix7.2.4.0. 2020-12-03 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> gcc: * doc/sourcebuild.texi (Commands for use in dg-final, Scan the assembly output, scan-assembler-symbol-section): Document. (scan-symbol-section): Document. gcc/testsuite: * lib/scanasm.exp (scan-symbol-section): Pass args to dg-scan-symbol-section. (scan-assembler-symbol-section): Likewise. (dg-scan-symbol-section): Handle selector from orig_args. Get patterns from orig_args. (parse_section_of_symbols): Fix section_pattern. Strip double quotes from section name. * g++.dg/gomp/tls-5.C: Restrict ir, _ZGR2ir_ scans to tls_native. * gcc.dg/20021029-1.c: Anchor ar symbol. * gcc.dg/darwin-sections.c: Remove obsolete scans for _a, _b in .data.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/g++.dg/gomp/tls-5.C4
-rw-r--r--gcc/testsuite/gcc.dg/20021029-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/darwin-sections.c2
-rw-r--r--gcc/testsuite/lib/scanasm.exp54
4 files changed, 39 insertions, 23 deletions
diff --git a/gcc/testsuite/g++.dg/gomp/tls-5.C b/gcc/testsuite/g++.dg/gomp/tls-5.C
index b18a127..eb187b6 100644
--- a/gcc/testsuite/g++.dg/gomp/tls-5.C
+++ b/gcc/testsuite/g++.dg/gomp/tls-5.C
@@ -1,8 +1,8 @@
// The reference temp should be TLS, not normal data.
// { dg-require-effective-target c++11 }
// { dg-final { scan-assembler-not "\\.data" { target tls_native xfail powerpc-*-aix* } } }
-// { dg-final { scan-assembler-symbol-section {^_?ir$} {^\.tbss|\[TL\]} } }
-// { dg-final { scan-assembler-symbol-section {^_?_ZGR2ir_$} {^\.tdata|\[TL\]} } }
+// { dg-final { scan-assembler-symbol-section {^_?ir$} {^\.tbss|\[TL\]} { target tls_native } } }
+// { dg-final { scan-assembler-symbol-section {^_?_ZGR2ir_$} {^\.tdata|\[TL\]} { target tls_native } } }
extern int&& ir;
#pragma omp threadprivate (ir)
diff --git a/gcc/testsuite/gcc.dg/20021029-1.c b/gcc/testsuite/gcc.dg/20021029-1.c
index 57c2b48..d13f669 100644
--- a/gcc/testsuite/gcc.dg/20021029-1.c
+++ b/gcc/testsuite/gcc.dg/20021029-1.c
@@ -3,7 +3,7 @@
/* { dg-do compile { target fpic } } */
/* { dg-options "-O2 -fpic" } */
/* { dg-final { scan-assembler-not ".data.rel.ro.local" } } */
-/* { dg-final { scan-assembler-symbol-section {ar} {^\.(const|rodata)|\[RO\]} } } */
+/* { dg-final { scan-assembler-symbol-section {^_?ar} {^\.(const|rodata)|\[RO\]} } } */
/* { dg-require-effective-target label_values } */
/* { dg-require-effective-target indirect_jumps } */
diff --git a/gcc/testsuite/gcc.dg/darwin-sections.c b/gcc/testsuite/gcc.dg/darwin-sections.c
index 5fc2860..dbe3702 100644
--- a/gcc/testsuite/gcc.dg/darwin-sections.c
+++ b/gcc/testsuite/gcc.dg/darwin-sections.c
@@ -10,9 +10,7 @@ typedef struct _empty {} e_s;
/* These should go in .comm */
char ub;
e_s ea;
-/* { dg-final { scan-assembler-symbol-section {^_a$} {\.data} } } */
/* { dg-final { scan-assembler ".comm\[\t \]_ub,1" } } */
-/* { dg-final { scan-assembler-symbol-section {^_b$} {\.data} } } */
/* { dg-final { scan-assembler ".comm\[\t \]_ea,1" } } */
/* These should go into __DATA,__common */
diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp
index 43b7649..18fef38 100644
--- a/gcc/testsuite/lib/scanasm.exp
+++ b/gcc/testsuite/lib/scanasm.exp
@@ -173,14 +173,8 @@ proc scan-assembler-symbol-section { args } {
set testcase [testname-for-summary]
set filename [lindex $testcase 0]
set output_file "[file rootname [file tail $filename]].s"
- set symbol_pattern [lindex $args 0]
- set expected_section_pattern [lindex $args 1]
dg-scan-symbol-section \
- "scan-assembler-symbol-section" \
- $testcase \
- $output_file \
- $symbol_pattern \
- $expected_section_pattern
+ "scan-assembler-symbol-section" $testcase $output_file $args
}
# Check that symbols are emitted in the desired section.
@@ -227,22 +221,44 @@ proc scan-assembler-symbol-section { args } {
proc scan-symbol-section { args } {
set testcase [testname-for-summary]
set output_file [lindex $args 0]
- set symbol_pattern [lindex $args 1]
- set expected_section_pattern [lindex $args 2]
dg-scan-symbol-section \
- "scan-symbol-section" \
- $testcase \
- $output_file \
- $symbol_pattern \
- $expected_section_pattern
+ "scan-symbol-section" $testcase $output_file $args
}
-# Check that symbols are emitted in the desired section.
+# Check that symbols are emitted in the desired section. The ORIG_ARGS is
+# the list of arguments provided by dg-final to scan-symbol-section or
+# scan-assembler-symbol-section. The first element in ORIG_ARGS is the
+# regular expression to look for in the file. The second element, if
+# present, is a DejaGNU target selector.
#
-# Avoid calling this function directly. In tests, use scan-symbol-section,
+# Avoid calling this function directly. In tests, use scan-symbol-section,
# scan-assembler-symbol-section, or scan-lto-assembler-symbol-section instead.
-proc dg-scan-symbol-section { name testcase output_file symbol_pattern expected_section_pattern } {
+proc dg-scan-symbol-section { name testcase output_file orig_args } {
+ if { [llength $orig_args] < 2 } {
+ error "$name: too few arguments"
+ return
+ }
+ if { [llength $orig_args] > 4 } {
+ error "$name: too many arguments"
+ return
+ }
+ switch $name {
+ "scan-symbol-section" { set arg_incr 1 }
+ default { set arg_incr 0 }
+ }
+ if { [llength $orig_args] >= 3 } {
+ switch [dg-process-target [lindex $orig_args [expr 2 + $arg_incr]]] {
+ "S" { }
+ "N" { return }
+ "F" { setup_xfail "*-*-*" }
+ "P" { }
+ }
+ }
+
+ set symbol_pattern [lindex $orig_args [expr 0 + $arg_incr]]
+ set expected_section_pattern [lindex $orig_args [expr 1 + $arg_incr]]
+
set printable_symbol_pattern [make_pattern_printable $symbol_pattern]
set printable_expected_section_pattern [make_pattern_printable $expected_section_pattern]
@@ -303,7 +319,7 @@ proc dg-scan-symbol-section { name testcase output_file symbol_pattern expected_
proc parse_section_of_symbols { filename result } {
upvar $result up_result
- set section_pattern {^\s*(?:(\.section|\.csect)\s+(.*)|(\.const|\.data|\.text)\s*)$}
+ set section_pattern {^\s*(?:(?:\.section|\.csect)\s+(.*)|(\.const|\.data|\.text)\s*)$}
set label_pattern {^(\S+):$}
set fd [open $filename r]
@@ -314,9 +330,11 @@ proc parse_section_of_symbols { filename result } {
} elseif { [regexp -- $section_pattern $line dummy section_directive_arguments full_section_directive] } {
if { $full_section_directive eq "" } {
# Example: .section .text,"ax",progbits
+ # Example: .section ".text",#alloc,#execinstr,#progbits
# Example: .section __TEXT,__text
set arguments [split $section_directive_arguments ","]
set current_section [string trim [lindex $arguments 0]]
+ set current_section [string trim $current_section {"}]
set arg_1 [string trim [lindex $arguments 1]]
if { [regexp {^_} $arg_1] } {
# The second argument looks like a Mach-O section name.