summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/CopyConfig.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-09-14 01:36:31 +0000
committerFangrui Song <maskray@google.com>2019-09-14 01:36:31 +0000
commit2f519d7072bf48a81985fadc2dc145296d612223 (patch)
tree8d0ca4b9f00f4d5b80e4023592951eeb3da84d39 /llvm/tools/llvm-objcopy/CopyConfig.cpp
parentba53030dd0938902dd858f7eac45732295e74120 (diff)
downloadbcm5719-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/CopyConfig.cpp')
-rw-r--r--llvm/tools/llvm-objcopy/CopyConfig.cpp32
1 files changed, 0 insertions, 32 deletions
diff --git a/llvm/tools/llvm-objcopy/CopyConfig.cpp b/llvm/tools/llvm-objcopy/CopyConfig.cpp
index 73e9221a476..a84114eb267 100644
--- a/llvm/tools/llvm-objcopy/CopyConfig.cpp
+++ b/llvm/tools/llvm-objcopy/CopyConfig.cpp
@@ -258,29 +258,6 @@ static Expected<NewSymbolInfo> parseNewSymbolInfo(StringRef FlagValue,
return SI;
}
-static const StringMap<MachineInfo> ArchMap{
- // Name, {EMachine, 64bit, LittleEndian}
- {"aarch64", {ELF::EM_AARCH64, true, true}},
- {"arm", {ELF::EM_ARM, false, true}},
- {"i386", {ELF::EM_386, false, true}},
- {"i386:x86-64", {ELF::EM_X86_64, true, true}},
- {"mips", {ELF::EM_MIPS, false, false}},
- {"powerpc:common64", {ELF::EM_PPC64, true, true}},
- {"riscv:rv32", {ELF::EM_RISCV, false, true}},
- {"riscv:rv64", {ELF::EM_RISCV, true, true}},
- {"sparc", {ELF::EM_SPARC, false, false}},
- {"sparcel", {ELF::EM_SPARC, false, true}},
- {"x86-64", {ELF::EM_X86_64, true, true}},
-};
-
-static Expected<const MachineInfo &> getMachineInfo(StringRef Arch) {
- auto Iter = ArchMap.find(Arch);
- if (Iter == std::end(ArchMap))
- return createStringError(errc::invalid_argument,
- "invalid architecture: '%s'", Arch.str().c_str());
- return Iter->getValue();
-}
-
struct TargetInfo {
FileFormat Format;
MachineInfo Machine;
@@ -489,15 +466,6 @@ Expected<DriverConfig> parseObjcopyOptions(ArrayRef<const char *> ArgsArr) {
.Case("binary", FileFormat::Binary)
.Case("ihex", FileFormat::IHex)
.Default(FileFormat::Unspecified);
- if (Config.InputFormat == FileFormat::Binary) {
- auto BinaryArch = InputArgs.getLastArgValue(OBJCOPY_binary_architecture);
- if (!BinaryArch.empty()) {
- Expected<const MachineInfo &> MI = getMachineInfo(BinaryArch);
- if (!MI)
- return MI.takeError();
- Config.BinaryArch = *MI;
- }
- }
if (opt::Arg *A = InputArgs.getLastArg(OBJCOPY_new_symbol_visibility)) {
const uint8_t Invalid = 0xff;
OpenPOWER on IntegriCloud