From 7575e6a752ecfa66a41a5d4636ed79524cb50ccb Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Tue, 27 Jun 2017 02:58:27 +0100 Subject: [PATCH] MIPS/LD/testsuite: mips-elf-flags: Add MIPS ABI Flags handling Complement commit 351cdf24d223 ("[MIPS] Implement O32 FPXX, FP64 and FP64A ABI extensions") and add optional MIPS ABI Flags handling to `good_combination' in the `mips-elf-flags.exp' test script. This lets callers of this procedure request to examine MIPS ABI Flags in addition to the `e_flags' member of the ELF file header so as to verify that flags are merged correctly by LD. The presence of further arguments triggers this verification, in which case `readelf' is called with the `-A' option additionally specified and the ISA member, the ISA Extension member and the ASEs member will be examined as per the arguments. Unlike with `readelf -h' output consider a failure to retrieve the member requested a test case failure rather than an unresolved result. This is because unlike with the `e_flags' member of the ELF file header which is always there in any valid ELF file the MIPS ABI Flags structure is optional in LD output and the absence of this structure when expected is surely a bug in LD. ld/ * testsuite/ld-mips-elf/mips-elf-flags.exp (good_combination): Add an `args' final argument and examination code for `readelf -A' output. Update procedure description accordingly. --- ld/ChangeLog | 6 +++ ld/testsuite/ld-mips-elf/mips-elf-flags.exp | 53 +++++++++++++++++++-- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 529850d4599..92d0003c305 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2017-06-27 Maciej W. Rozycki + + * testsuite/ld-mips-elf/mips-elf-flags.exp (good_combination): + Add an `args' final argument and examination code for `readelf + -A' output. Update procedure description accordingly. + 2017-06-27 Maciej W. Rozycki * testsuite/ld-mips-elf/mips-elf-flags.exp (good_combination): diff --git a/ld/testsuite/ld-mips-elf/mips-elf-flags.exp b/ld/testsuite/ld-mips-elf/mips-elf-flags.exp index 9461cb600e3..dbe4132c568 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf-flags.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf-flags.exp @@ -57,8 +57,13 @@ proc assemble_for_flags {arglist} { # Assemble a file using each set of arguments in ARGLIST. Check that # the objects can be linked together and that the `readelf -h' output -# includes each flag named in FLAGS. -proc good_combination {arglist flags} { +# includes each flag named in FLAGS. Additional one or more arguments +# request the addition of the `-A' option to `readelf' invocation. In +# this case check MIPS ABI Flags reported for the ISA to match the +# first of these arguments, the ISA Extension to match the second, and +# the ASEs listed are exactly the same as those listed in the third, +# passed as a TCL list. +proc good_combination {arglist flags args} { global ld ldemul READELF set finalobj "tmpdir/mips-flags.o" @@ -70,7 +75,8 @@ proc good_combination {arglist flags} { } elseif {![ld_link "$ld $ldemul" $finalobj "-r $objs"]} { fail $testname } else { - set cmd "$READELF -h $finalobj" + set A [expr {[llength $args] > 0} ? {"A"} : {""}] + set cmd "$READELF -h$A $finalobj" send_log "$cmd\n" set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]]] set output [lindex $cmdret 1] @@ -91,6 +97,47 @@ proc good_combination {arglist flags} { set failed 1 } } + + set isa [string trim [lindex $args 0]] + if {$isa != "" + && (![regexp "ISA: *(\[^\n\r\]*)" $output full gotisa] + || ![string match $isa $gotisa])} { + set failed 1 + } + + set ext [string trim [lindex $args 1]] + if {$ext != "" + && (![regexp "ISA Extension: *(\[^\n\r\]*)" \ + $output full gotext] + || ![string match $ext $gotext])} { + set failed 1 + } + + set ases [string trim [lindex $args 2]] + if {[llength $ases] > 0} { + if {![regexp "ASEs:\[\n\r\]+((?:\t\[^\n\r\]*\[\n\r\]+)*)" \ + $output full gotases]} { + set failed 1 + } else { + # GOTASES is a list of strings separated by tab and + # line separator characters. Convert it to a TCL list. + regsub -all "\[\n\r\t\]+" $gotases "\n" gotases + set gotases [split [string trim $gotases] "\n"] + + foreach ase $ases { + set aseidx [lsearch -exact $gotases $ase] + if {$aseidx >= 0} { + set gotases [lreplace $gotases $aseidx $aseidx] + } else { + set failed 1 + } + } + if {[llength $gotases] > 0} { + set failed 1 + } + } + } + if {$failed} { fail $testname } else { -- 2.30.2