[PATCH] D67215: [llvm-objcopy] Ignore -B --binary-architecture=

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 01:37:17 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.

GNU objcopy documents that -B is only useful with architecture-less
input (i.e. "binary" or "ihex"). After D67144 <https://reviews.llvm.org/D67144>, -O defaults to -I, and
-B is essentially a NOP.

- If -O is binary, GNU objcopy ignores -B.
- If -O is elf*, -B provides the e_machine field in GNU objcopy.

So to convert a blob to an ELF, `-I binary -B i386:x86-64 -O elf64-x86-64` has to be specified.

`-I binary -B i386:x86-64 -O elf64-x86-64` creates an ELF with its
e_machine field set to EM_NONE in GNU objcopy, but a regular x86_64 ELF
in elftoolchain elfcopy. Follow the elftoolchain approach (ignoring -B)
to simplify code. Users that expect their command line portable should
specify -B.


Repository:
  rL LLVM

https://reviews.llvm.org/D67215

Files:
  test/tools/llvm-objcopy/ELF/binary-input-error.test
  tools/llvm-objcopy/CopyConfig.cpp
  tools/llvm-objcopy/CopyConfig.h
  tools/llvm-objcopy/ELF/ELFObjcopy.cpp
  tools/llvm-objcopy/ELF/Object.cpp
  tools/llvm-objcopy/ELF/Object.h
  tools/llvm-objcopy/ObjcopyOpts.td

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67215.218858.patch
Type: text/x-patch
Size: 7241 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190905/ddef643d/attachment.bin>


More information about the llvm-commits mailing list