From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12769 invoked by alias); 27 May 2014 14:04:59 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 12754 invoked by uid 89); 27 May 2014 14:04:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 May 2014 14:04:55 +0000 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id 8B7B1EABBC272; Tue, 27 May 2014 15:04:49 +0100 (IST) Received: from KLMAIL02.kl.imgtec.org (192.168.5.97) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 27 May 2014 15:04:51 +0100 Received: from LEMAIL01.le.imgtec.org (192.168.152.62) by klmail02.kl.imgtec.org (192.168.5.97) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 27 May 2014 15:04:51 +0100 Received: from LEMAIL01.le.imgtec.org ([fe80::5ae:ee16:f4b9:cda9]) by LEMAIL01.le.imgtec.org ([fe80::5ae:ee16:f4b9:cda9%17]) with mapi id 14.03.0174.001; Tue, 27 May 2014 15:04:51 +0100 From: Matthew Fortune To: "binutils@sourceware.org" CC: Richard Sandiford Subject: [PATCH] Add an optional objcopy stage between gas and ld in run_dump_test Date: Tue, 27 May 2014 14:04:00 -0000 Message-ID: <6D39441BF12EF246A7ABCE6654B0235353F94B@LEMAIL01.le.imgtec.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2014-05/txt/msg00226.txt.bz2 As part of testing new MIPS ABI extensions I found a need to modify objects between assembly and linking to trigger linker logic which handles partly corrupted objects. In my case I needed to remove a section and while strip can do this too, objcopy will be more flexible for other uses in the future. The feature adds a new keyword: objcopy_objects which takes the flags for objcopy. It also adds a pseudo-option for source specific assembly flags called RUN_OBJCOPY. Any source with this pseudo-option will have its corresponding object run through objcopy with the specified flags and then go on to link as usual. An example usage: #source: jr.s -march=3Docteon -32 -mfp64 -EB RUN_OBJCOPY #source: jr.s -mips32r2 -32 -mfpxx -EB #ld: -melf32btsmip -e 0 #objcopy_objects: -R .MIPS.abiflags #objdump: -p This will remove .MIPS.abiflags from the first object but not the second and then link. Comments/OK to commit? Regards, Matthew 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/lib/ld-lib.exp | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 369dc1f..c3af59c 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) {} =20 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 =20 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] !=3D 0 \ + || ![string match "" $comp_output] } { + send_log "$comp_output\n" + verbose "$comp_output" 3 + + set exitstat "succeeded" + if { $cmdret !=3D 0 } { set exitstat "failed" } + verbose -log "$exitstat with: <$comp_output>" + fail $testname + return + } + } } =20 set expmsg $opts(error) --=20 1.7.1