Bug 19020 - objcopy interleave feature broken
Summary: objcopy interleave feature broken
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.26
Assignee: H.J. Lu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-29 14:09 UTC by Andrew Stubbs
Modified: 2016-10-14 14:06 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
A patch (1.56 KB, patch)
2015-09-29 15:52 UTC, H.J. Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Stubbs 2015-09-29 14:09:06 UTC
The recent fix for pr binutils/19005 broke the interleave feature.

Before the "fix":

$ echo -n abcdefgh > in
$ objcopy -I binary -O binary \
          --pad-to=10 --gap-fill=65 \
          --interleave=2 --interleave-width=1 --byte=0 \
          in out
$ xxd out
0000000: 6163 6567 4141 4141 4141                 acegAAAAAA


After@

$ objcopy -I binary -O binary \
          --pad-to=10 --gap-fill=65 \
          --interleave=2 --interleave-width=1 --byte=0 \
          in out
$ xxd out
0000000: 6163 0000 4141 4141 4141                 ac..AAAAAA
              ^^^^                                  ^^
Comment 1 H.J. Lu 2015-09-29 15:08:52 UTC
Do you use --reverse-bytes?  There are no testcase for --reverse-bytes
with --pad-to=.
Comment 2 Andrew Stubbs 2015-09-29 15:12:07 UTC
My patch in PR19005 has a testcase for --reverse-bytes, but that test passes.
Comment 3 H.J. Lu 2015-09-29 15:24:13 UTC
(In reply to Andrew Stubbs from comment #2)
> My patch in PR19005 has a testcase for --reverse-bytes, but that test passes.

Does your testcase for --reverse-bytes generate output? I am looking
for a testcase of --reverse-bytes --pad-to=XXX which generate an
output.
Comment 4 Andrew Stubbs 2015-09-29 15:28:59 UTC
It generates an output file, the same as the interleave test does:

$ echo -n abcdefgh > in
$ objcopy -I binary -O binary \
          --pad-to=10 --gap-fill=65 \
          --reverse-bytes=8 \
          in out
$ xxd out
0000000: 6867 6665 6463 6261 4141                 hgfedcbaAA
Comment 5 H.J. Lu 2015-09-29 15:52:31 UTC
Created attachment 8644 [details]
A patch

Please try this.
Comment 6 H.J. Lu 2015-09-29 17:14:50 UTC
A patch is posted at

https://sourceware.org/ml/binutils/2015-09/msg00314.html

Please give it a try.
Comment 7 Sourceware Commits 2015-09-29 20:34:09 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cbd44e247ede49688e1e1fa42e57d390ad141967

commit cbd44e247ede49688e1e1fa42e57d390ad141967
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Sep 29 09:35:47 2015 -0700

    Don't use the output section size to copy input section
    
    We can't use the output section size to copy input section since
    --interleave will shrink the output section.  Instead, we change
    bfd_convert_section_contents to return the updated input section
    size.  When we do that, we don't need to adjust the output section
    size to skip gap fills.
    
    bfd/
    
    	PR binutils/19020
    	* bfd.c (bfd_convert_section_contents): Add ptr_size parameter.
    	* bfd-in2.h: Regenerated.
    
    binutils/
    
    	PR binutils/19020
    	* objcopy.c (copy_object): Don't adjust the output section size
    	when copying from input sections.
    	(copy_section): Use input section size for the copy.  Get the
    	updated section size from bfd_convert_section_contents.
    
    binutils/testsuite/
    
    	PR binutils/19020
    	* binutils-all/objcopy.exp: Run pr19020a and pr19020b.
    	* lib/utils-lib.exp (run_dump_test): Support binary input.
    	* binutils-all/pr19020.in: New file.
    	* binutils-all/pr19020a.d: Likewise.
    	* binutils-all/pr19020b.d: Likewise.
Comment 8 H.J. Lu 2015-09-29 20:51:06 UTC
Fixed.
Comment 9 Sandra Loosemore 2016-10-07 05:33:22 UTC
The test cases added for this PR are failing in remote-host testing because the piece added to run_dump_test is only copying the file locally and not downloading it to the remote host.  So the tests end up running objcopy on whatever $tempfile was left over on the remote host from the previous test, instead of the intended file.
Comment 10 H.J. Lu 2016-10-07 15:35:48 UTC
(In reply to sandra from comment #9)
> The test cases added for this PR are failing in remote-host testing because
> the piece added to run_dump_test is only copying the file locally and not
> downloading it to the remote host.  So the tests end up running objcopy on
> whatever $tempfile was left over on the remote host from the previous test,
> instead of the intended file.

Can you provide a patch?
Comment 11 Sourceware Commits 2016-10-14 14:06:39 UTC
The master branch has been updated by Luis Machado <luisgpm@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e913b9cb939c45ce9cbf0f224da6466cd3094c3a

commit e913b9cb939c45ce9cbf0f224da6466cd3094c3a
Author: Luis Machado <lgustavo@codesourcery.com>
Date:   Fri Oct 14 09:04:46 2016 -0500

    Fix leftover remote test failures from PR binutils/19020
    
    As pointed out in PR binutils/19020, those tests were still failing when doing
    remote testing. This is because the binary files weren't being copied over to
    the remote host for testing.
    
    FAIL: binutils-all/pr19020a
    FAIL: binutils-all/pr19020b
    
    This small patch fixes this up to make things pass.
    
    binutils/ChangeLog:
    2016-10-14  Luis Machado  <lgustavo@codesourcery.com>
    
    	* testsuite/lib/utils-lib.exp (run_dump_test): Call remote_download
    	to copy file to remote host.