* [PATCH] Add an optional objcopy stage between gas and ld in run_dump_test
@ 2014-05-27 14:04 Matthew Fortune
2014-05-27 14:16 ` Richard Sandiford
0 siblings, 1 reply; 2+ messages in thread
From: Matthew Fortune @ 2014-05-27 14:04 UTC (permalink / raw)
To: binutils; +Cc: Richard Sandiford
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=octeon -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) {}
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)
--
1.7.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Add an optional objcopy stage between gas and ld in run_dump_test
2014-05-27 14:04 [PATCH] Add an optional objcopy stage between gas and ld in run_dump_test Matthew Fortune
@ 2014-05-27 14:16 ` Richard Sandiford
0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2014-05-27 14:16 UTC (permalink / raw)
To: Matthew Fortune; +Cc: binutils
Matthew Fortune <Matthew.Fortune@imgtec.com> writes:
> 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.
OK if no objections in 24 hours.
Thanks,
Richard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-27 14:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-27 14:04 [PATCH] Add an optional objcopy stage between gas and ld in run_dump_test Matthew Fortune
2014-05-27 14:16 ` Richard Sandiford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).