[PATCH] D67144: [llvm-objcopy] Set --output-target to --input-target is unspecified

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 23:34:32 PDT 2019


MaskRay created this revision.
MaskRay added reviewers: alexshap, grimar, jakehehrlich, jhenderson, rupprecht.
Herald added subscribers: llvm-commits, seiya, s.egerton, abrachet, simoncook, fedor.sergeev, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

Fixes PR42171.

In GNU objcopy, is -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. GNU objcopy has another
strange behavior:

  objcopy -I binary -O elf64-x86-64 a.txt b.o   # e_machine is EM_NONE
  objcopy -I binary -B i386:x86-64 -O elf64-x86-64 a.txt b.o   # e_machine is EM_X86_64

We just fill in the e_machine field regardless of -B.


Repository:
  rL LLVM

https://reviews.llvm.org/D67144

Files:
  test/tools/llvm-objcopy/ELF/binary-input-and-output.test
  test/tools/llvm-objcopy/ELF/binary-input-arch.test
  test/tools/llvm-objcopy/ELF/binary-input-error.test
  test/tools/llvm-objcopy/ELF/binary-input.test
  test/tools/llvm-objcopy/ELF/binary-output-target.test
  test/tools/llvm-objcopy/ELF/new-symbol-visibility.test
  tools/llvm-objcopy/CopyConfig.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67144.218596.patch
Type: text/x-patch
Size: 10583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190904/a4f8a869/attachment.bin>


More information about the llvm-commits mailing list