This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy] Ignore -B --binary-architecture=
ClosedPublic

Authored by MaskRay on Sep 5 2019, 1:34 AM.

Details

Summary

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

  • If -O is binary/ihex, 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.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.Sep 5 2019, 1:34 AM

Please could you update the docs with this change. I completely agree with following the elf toolchain approach here.

MaskRay updated this revision to Diff 218879.Sep 5 2019, 3:20 AM

Update docs/CommandGuide/llvm-objcopy.rst

jhenderson accepted this revision.Sep 5 2019, 5:36 AM

LGTM, aside from one comment. Perhaps worth confirming with @jakehehrlich about it?

docs/CommandGuide/llvm-objcopy.rst
180–182 ↗(On Diff #218879)

As this is now ignored, perhaps this can be moved to the generic options section, rather than ELF-specific?

This revision is now accepted and ready to land.Sep 5 2019, 5:36 AM
MaskRay updated this revision to Diff 218900.Sep 5 2019, 5:51 AM
MaskRay marked an inline comment as done.
MaskRay edited the summary of this revision. (Show Details)

Move -B from "ELF-specific" section to generic options section