diff options
author | Fangrui Song <maskray@google.com> | 2019-09-14 01:36:31 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-09-14 01:36:31 +0000 |
commit | 2f519d7072bf48a81985fadc2dc145296d612223 (patch) | |
tree | 8d0ca4b9f00f4d5b80e4023592951eeb3da84d39 /llvm/tools/llvm-objcopy/ELF/Object.cpp | |
parent | ba53030dd0938902dd858f7eac45732295e74120 (diff) | |
download | llvm-2f519d7072bf48a81985fadc2dc145296d612223.zip llvm-2f519d7072bf48a81985fadc2dc145296d612223.tar.gz llvm-2f519d7072bf48a81985fadc2dc145296d612223.tar.bz2 |
[llvm-objcopy] Ignore -B --binary-architecture=
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.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D67215
llvm-svn: 371914
Diffstat (limited to 'llvm/tools/llvm-objcopy/ELF/Object.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/ELF/Object.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/tools/llvm-objcopy/ELF/Object.cpp b/llvm/tools/llvm-objcopy/ELF/Object.cpp index 3d1527c..79f10fe 100644 --- a/llvm/tools/llvm-objcopy/ELF/Object.cpp +++ b/llvm/tools/llvm-objcopy/ELF/Object.cpp @@ -1112,7 +1112,7 @@ void BasicELFBuilder::initFileHeader() { Obj->OSABI = ELFOSABI_NONE; Obj->ABIVersion = 0; Obj->Entry = 0x0; - Obj->Machine = EMachine; + Obj->Machine = EM_NONE; Obj->Version = 1; } @@ -1606,7 +1606,7 @@ Writer::~Writer() {} Reader::~Reader() {} std::unique_ptr<Object> BinaryReader::create() const { - return BinaryELFBuilder(MInfo.EMachine, MemBuf, NewSymbolVisibility).build(); + return BinaryELFBuilder(MemBuf, NewSymbolVisibility).build(); } Expected<std::vector<IHexRecord>> IHexReader::parse() const { |