This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [committed, PATCH] Properly convert objects between different ELF classes

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.

2015-09-24  Andrew Stubbs  <>

	* 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)"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]