[gcc r17-1719] testsuite, darwin: Handle Darwin LTO section names.
Iain D Sandoe
iains@gcc.gnu.org
Sat Jun 20 16:12:47 GMT 2026
https://gcc.gnu.org/g:0266ef2156f481c0d8aac119d0dffe99fb9bf7c1
commit r17-1719-g0266ef2156f481c0d8aac119d0dffe99fb9bf7c1
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Mon May 6 00:01:36 2024 +0100
testsuite, darwin: Handle Darwin LTO section names.
This recognises the .section __GNU_LTO, segment prefix used by Darwin
to skip LTO sections there and splits this into a separate function
since it is used several times.
PR testsuite/112728
gcc/testsuite/ChangeLog:
* lib/scanasm.exp (remove_lto_sections): New.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Diff:
---
gcc/testsuite/lib/scanasm.exp | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp
index 422d874ca4ce..897ce76eae54 100644
--- a/gcc/testsuite/lib/scanasm.exp
+++ b/gcc/testsuite/lib/scanasm.exp
@@ -37,6 +37,21 @@ proc append_encoding_arg { args enc } {
return $args
}
+# Remove LTO-prefixed sections from TEXT.
+
+proc remove_lto_sections { text } {
+ set p1 {(^|\n)[[:space:]]*\.section[[:space:]]*"?}
+ set lto_sect_prefix {\.gnu\.lto_}
+ set p3 {(?:[^\n]*\n(?![[:space:]]*\.(section|text|data|bss)))*[^\n]*\n}
+ if { [istarget *-*-darwin*] } {
+ # Darwin/Mach-O LTO sections are in the __GNU_LTO segment.
+ set lto_sect_prefix {__GNU_LTO}
+ }
+ set patt ${p1}${lto_sect_prefix}${p3}
+ regsub -all ${patt} $text {\1} text
+ return $text
+}
+
# Scan the OUTPUT_FILE for a pattern. If it is present and POSITIVE
# is non-zero, or it is not present and POSITIVE is zero, the test
# passes. The ORIG_ARGS is the list of arguments provided by dg-final
@@ -80,10 +95,8 @@ proc dg-scan { name positive testcase output_file orig_args } {
set text [read $fd]
close $fd
if { [string compare -length 14 $name scan-assembler] == 0 } {
- # Remove LTO sections.
- # ??? Somehow, .*? is still greedy.
- # regsub -all {(^|\n)[[:space:]]*\.section[[:space:]]*"?\.gnu\.lto_.*?\n(?=[[:space:]]*\.text\n)} $text {\1} text
- regsub -all {(^|\n)[[:space:]]*\.section[[:space:]]*"?\.gnu\.lto_(?:[^\n]*\n(?![[:space:]]*\.(section|text|data|bss)))*[^\n]*\n} $text {\1} text
+ # Remove LTO sections.
+ set text [remove_lto_sections $text]
}
set match [regexp -- $pattern $text]
@@ -550,8 +563,8 @@ proc scan-assembler-times { args } {
set fd [open $output_file r]
set text [read $fd]
close $fd
- regsub -all {(^|\n)[[:space:]]*\.section[[:space:]]*"?\.gnu\.lto_(?:[^\n]*\n(?![[:space:]]*\.(section|text|data|bss)))*[^\n]*\n} $text {\1} text
-
+ # Remove LTO sections.
+ set text [remove_lto_sections $text]
set result_count [regexp -all -- $pattern $text]
if {$result_count == $times} {
pass "$testcase scan-assembler-times $pp_pattern $times"
@@ -614,7 +627,7 @@ proc scan-assembler-bound { args } {
set fd [open $output_file r]
set text [read $fd]
close $fd
- regsub -all {(^|\n)[[:space:]]*\.section[[:space:]]*"?\.gnu\.lto_(?:[^\n]*\n(?![[:space:]]*\.(section|text|data|bss)))*[^\n]*\n} $text {\1} text
+ set text [remove_lto_sections $text]
set result_count [regexp -all -- $pattern $text]
if [expr $result_count $cmp $bound] {
@@ -676,7 +689,7 @@ proc scan-assembler-dem { args } {
set output [remote_exec host "$cxxfilt" "" "$output_file"]
set text [lindex $output 1]
- regsub -all {(^|\n)[[:space:]]*\.section[[:space:]]*"?\.gnu\.lto_(?:[^\n]*\n(?![[:space:]]*\.(section|text|data|bss)))*[^\n]*\n} $text {\1} text
+ set text [remove_lto_sections $text]
if [regexp -- $pattern $text] {
pass "$testcase scan-assembler-dem $pp_pattern"
@@ -733,7 +746,7 @@ proc scan-assembler-dem-not { args } {
set output [remote_exec host "$cxxfilt" "" "$output_file"]
set text [lindex $output 1]
- regsub -all {(^|\n)[[:space:]]*\.section[[:space:]]*"?\.gnu\.lto_(?:[^\n]*\n(?![[:space:]]*\.(section|text|data|bss)))*[^\n]*\n} $text {\1} text
+ set text [remove_lto_sections $text]
if ![regexp -- $pattern $text] {
pass "$testcase scan-assembler-dem-not $pp_pattern"
More information about the Gcc-cvs
mailing list