From 9854d43d40fc116d72a24583f53e34f91cf4098b Mon Sep 17 00:00:00 2001 From: mfortune Date: Tue, 27 May 2014 12:37:50 +0100 Subject: [PATCH] Add objcopy stage between assembly and linking for run_dump_test ld/testsuite/ * lib/ld-lib.exp: Add objcopy_objects command to run_dump_test. This allows each input object to be optionally run through objcopy before linking. --- ld/testsuite/ChangeLog | 6 ++++++ ld/testsuite/lib/ld-lib.exp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 158d9a6..bd604b6 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-05-28 Matthew Fortune + + * lib/ld-lib.exp: Add objcopy_objects command to run_dump_test. + This allows each input object to be optionally run through + objcopy before linking. + 2014-05-20 Will Newton * ld-shared/shared.exp: Mark non-PIC shared object tests diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 369dc1f..27bfc08 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -497,6 +497,11 @@ proc ld_simple_link_defsyms {} { # ld_after_inputfiles: FLAGS # Similar to "ld", but put after all input files. # +# objcopy_objects: FLAGS +# Run objcopy with the specified flags after assembling any source +# that has the special marker RUN_OBJCOPY in the source specific +# flags. +# # objcopy_linked_file: FLAGS # Run objcopy on the linked file with the specified flags. # This lets you transform the linked file using objcopy, before the @@ -605,6 +610,7 @@ proc run_dump_test { name {extra_options {}} } { set opts(error) {} set opts(warning) {} set opts(objcopy_linked_file) {} + set opts(objcopy_objects) {} foreach i $opt_array { set opt_name [lindex $i 0] @@ -784,6 +790,12 @@ proc run_dump_test { name {extra_options {}} } { for { set i 0 } { $i < [llength $sourcefiles] } { incr i } { set sourcefile [lindex $sourcefiles $i] set sourceasflags [lindex $asflags $i] + set run_objcopy_objects 0 + + if { [string match "*RUN_OBJCOPY*" $sourceasflags] } { + set run_objcopy_objects 1 + } + regsub "RUN_OBJCOPY" $sourceasflags "" sourceasflags set objfile "tmpdir/dump$i.o" catch "exec rm -f $objfile" exec_output @@ -807,6 +819,30 @@ proc run_dump_test { name {extra_options {}} } { fail $testname return } + + if { $run_objcopy_objects } { + set cmd "$OBJCOPY $opts(objcopy_objects) $objfile" + + send_log "$cmd\n" + set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]] \ + "" "/dev/null" "objcopy.tmp"] + remote_upload host "objcopy.tmp" + set comp_output [prune_warnings [file_contents "objcopy.tmp"]] + remote_file host delete "objcopy.tmp" + remote_file build delete "objcopy.tmp" + + if { [lindex $cmdret 0] != 0 \ + || ![string match "" $comp_output] } { + send_log "$comp_output\n" + verbose "$comp_output" 3 + + set exitstat "succeeded" + if { $cmdret != 0 } { set exitstat "failed" } + verbose -log "$exitstat with: <$comp_output>" + fail $testname + return + } + } } set expmsg $opts(error) -- 2.7.4