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.h | |
| parent | ba53030dd0938902dd858f7eac45732295e74120 (diff) | |
| download | bcm5719-llvm-2f519d7072bf48a81985fadc2dc145296d612223.tar.gz bcm5719-llvm-2f519d7072bf48a81985fadc2dc145296d612223.zip | |
[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.h')
| -rw-r--r-- | llvm/tools/llvm-objcopy/ELF/Object.h | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/tools/llvm-objcopy/ELF/Object.h b/llvm/tools/llvm-objcopy/ELF/Object.h index 0ff455d540f..d74b5f410af 100644 --- a/llvm/tools/llvm-objcopy/ELF/Object.h +++ b/llvm/tools/llvm-objcopy/ELF/Object.h @@ -873,7 +873,6 @@ using object::OwningBinary; class BasicELFBuilder { protected: - uint16_t EMachine; std::unique_ptr<Object> Obj; void initFileHeader(); @@ -883,8 +882,7 @@ protected: void initSections(); public: - BasicELFBuilder(uint16_t EM) - : EMachine(EM), Obj(std::make_unique<Object>()) {} + BasicELFBuilder() : Obj(std::make_unique<Object>()) {} }; class BinaryELFBuilder : public BasicELFBuilder { @@ -893,8 +891,8 @@ class BinaryELFBuilder : public BasicELFBuilder { void addData(SymbolTableSection *SymTab); public: - BinaryELFBuilder(uint16_t EM, MemoryBuffer *MB, uint8_t NewSymbolVisibility) - : BasicELFBuilder(EM), MemBuf(MB), + BinaryELFBuilder(MemoryBuffer *MB, uint8_t NewSymbolVisibility) + : BasicELFBuilder(), MemBuf(MB), NewSymbolVisibility(NewSymbolVisibility) {} std::unique_ptr<Object> build(); @@ -907,7 +905,7 @@ class IHexELFBuilder : public BasicELFBuilder { public: IHexELFBuilder(const std::vector<IHexRecord> &Records) - : BasicELFBuilder(ELF::EM_386), Records(Records) {} + : BasicELFBuilder(), Records(Records) {} std::unique_ptr<Object> build(); }; @@ -942,14 +940,12 @@ public: }; class BinaryReader : public Reader { - const MachineInfo &MInfo; MemoryBuffer *MemBuf; uint8_t NewSymbolVisibility; public: - BinaryReader(const MachineInfo &MI, MemoryBuffer *MB, - const uint8_t NewSymbolVisibility) - : MInfo(MI), MemBuf(MB), NewSymbolVisibility(NewSymbolVisibility) {} + BinaryReader(MemoryBuffer *MB, const uint8_t NewSymbolVisibility) + : MemBuf(MB), NewSymbolVisibility(NewSymbolVisibility) {} std::unique_ptr<Object> create() const override; }; |

