This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [committed, PATCH] Properly convert objects between different ELF classes
- From: Andrew Stubbs <ams at codesourcery dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Thu, 24 Sep 2015 18:44:54 +0100
- Subject: Re: [committed, PATCH] Properly convert objects between different ELF classes
- Authentication-results: sourceware.org; auth=none
- References: <20150710214315 dot GA17734 at intel dot com> <56041251 dot 6060203 at codesourcery dot com> <CAMe9rOrwOq5xx9QsbQMY17MKPrc_Yrv+4i4y0Nyk8jh4s-qSsg at mail dot gmail dot com> <560413B3 dot 9090307 at mentor dot com> <CAMe9rOprioH7sqnb5Q8y5Um8pVs_OnEFGxmsqYOq-rBeUEQS2g at mail dot gmail dot com>
On 24/09/15 16:31, H.J. Lu wrote:
Will it ever lead to wrong result with byte reversal and interleaving?
Good point. The attached detects the problem, indirectly.
Andrew
2015-09-24 Andrew Stubbs <ams@codesourcery.com>
binutils/testsuite/
* binutils-all/three-byte-text.s: New file.
* binutils-all/objcopy.exp (use input sizes): New test.
Index: binutils/testsuite/binutils-all/three-byte-text.s
===================================================================
--- binutils/testsuite/binutils-all/three-byte-text.s (revision 0)
+++ binutils/testsuite/binutils-all/three-byte-text.s (revision 0)
@@ -0,0 +1,2 @@
+ .text
+ .byte 1,2,3
Index: binutils/testsuite/binutils-all/objcopy.exp
===================================================================
--- binutils/testsuite/binutils-all/objcopy.exp (revision 455071)
+++ binutils/testsuite/binutils-all/objcopy.exp (working copy)
@@ -1095,3 +1095,20 @@
run_dump_test "exclude-1b"
}
run_dump_test "localize-hidden-2"
+
+# Section copies should copy more data than there is in the input
+# (i.e. read past end of buffer)
+# We can't test this directly without valgrind, but --reverse-bytes
+# ought to use the same value.
+if {[binutils_assemble $srcdir/$subdir/three-byte-text.s tmpdir/bintest.o]} then {
+ set got [binutils_run $OBJCOPY "-O binary -j .text --pad-to=4 --reverse-bytes=4 tmpdir/bintest.o"]
+
+ if [regexp {cannot reverse bytes: length of section .text must be evenly divisible by 4} $got] then {
+ pass "objcopy (use input sizes)"
+ } else {
+ fail "objcopy (use input sizes)"
+ }
+} else {
+ perror "unresolved use input sizes"
+ unresolved "objcopy (use input sizes)"
+}