[llvm-objcopy] Default --output-target to --input-target when unspecified
authorFangrui Song <maskray@google.com>
Sat, 14 Sep 2019 01:36:16 +0000 (01:36 +0000)
committerFangrui Song <maskray@google.com>
Sat, 14 Sep 2019 01:36:16 +0000 (01:36 +0000)
commitba53030dd0938902dd858f7eac45732295e74120
tree77f51df48d84d05bfae455e8cb0757d0214a279c
parent8a468031cd0b088d0f0b01df72d981885a6d4e89
[llvm-objcopy] Default --output-target to --input-target when unspecified

Fixes PR42171.

In GNU objcopy, if -O (--output-target) is not specified, the value is
copied from -I (--input-target).

```
objcopy -I binary -B i386:x86-64 a.txt b       # b is copied from a.txt
llvm-objcopy -I binary -B i386:x86-64 a.txt b  # b is an x86-64 object file
```

This patch changes our behavior to match GNU. With this change, we can
delete code related to -B handling (D67215).

Reviewed By: jakehehrlich

Differential Revision: https://reviews.llvm.org/D67144

llvm-svn: 371913
llvm/test/tools/llvm-objcopy/ELF/binary-input-and-output.test
llvm/test/tools/llvm-objcopy/ELF/binary-input-error.test
llvm/test/tools/llvm-objcopy/ELF/binary-input.test
llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test [moved from llvm/test/tools/llvm-objcopy/ELF/binary-input-arch.test with 72% similarity]
llvm/test/tools/llvm-objcopy/ELF/new-symbol-visibility.test
llvm/tools/llvm-objcopy/CopyConfig.cpp