From: mfortune Date: Tue, 27 May 2014 11:37:50 +0000 (+0100) Subject: Add objcopy stage between assembly and linking for run_dump_test X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9854d43d40fc116d72a24583f53e34f91cf4098b;p=binutils-gdb.git 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. --- diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 158d9a699a5..bd604b63813 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 369dc1f7a1b..27bfc08e945 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)