diff options
author | Rumeet Dhindsa <rdhindsa@google.com> | 2019-06-26 03:00:57 +0000 |
---|---|---|
committer | Rumeet Dhindsa <rdhindsa@google.com> | 2019-06-26 03:00:57 +0000 |
commit | 4ee933c76bf2a81e7d843c878ac80e8d67eaa535 (patch) | |
tree | 5a004357b109458fd083942082dee251e1c91504 /llvm/tools/llvm-objcopy/llvm-objcopy.cpp | |
parent | Revert [llvm-objcopy][NFCI] Fix build failure with GCC (diff) | |
download | llvm-project-4ee933c76bf2a81e7d843c878ac80e8d67eaa535.tar.gz llvm-project-4ee933c76bf2a81e7d843c878ac80e8d67eaa535.tar.bz2 llvm-project-4ee933c76bf2a81e7d843c878ac80e8d67eaa535.zip |
Revert [llvm-objcopy][NFC] Refactor output target parsing
This reverts r364254 (git commit 545f001d1b9a7b58a68d75e70bfc36c841de8999)
This change causes some llvm-obcopy tests to fail with valgrind.
Following is the output for basic-keep.test
Command Output (stderr):
--
==107406== Conditional jump or move depends on uninitialised value(s)
==107406== at 0x1A30DD: executeObjcopy(llvm::objcopy::CopyConfig const&) (llvm-objcopy.cpp:235)
==107406== by 0x1A3935: main (llvm-objcopy.cpp:294)
llvm-svn: 364379
Diffstat (limited to 'llvm/tools/llvm-objcopy/llvm-objcopy.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/llvm-objcopy.cpp | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp index 44e0220a7d37..2ab77ea5c868 100644 --- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -140,16 +140,11 @@ static Error executeObjcopyOnIHex(const CopyConfig &Config, MemoryBuffer &In, /// of the output specified by the command line options. static Error executeObjcopyOnRawBinary(const CopyConfig &Config, MemoryBuffer &In, Buffer &Out) { - switch (Config.OutputFormat) { - case FileFormat::ELF: - // FIXME: Currently, we call elf::executeObjcopyOnRawBinary even if the - // output format is binary/ihex or it's not given. This behavior differs from - // GNU objcopy. See https://bugs.llvm.org/show_bug.cgi?id=42171 for details. - case FileFormat::Binary: - case FileFormat::IHex: - case FileFormat::Unspecified: - return elf::executeObjcopyOnRawBinary(Config, In, Out); - } + // TODO: llvm-objcopy should parse CopyConfig.OutputFormat to recognize + // formats other than ELF / "binary" and invoke + // elf::executeObjcopyOnRawBinary, macho::executeObjcopyOnRawBinary or + // coff::executeObjcopyOnRawBinary accordingly. + return elf::executeObjcopyOnRawBinary(Config, In, Out); } /// The function executeObjcopyOnBinary does the dispatch based on the format @@ -229,17 +224,10 @@ static Error executeObjcopy(const CopyConfig &Config) { return createFileError(Config.InputFilename, EC); typedef Error (*ProcessRawFn)(const CopyConfig &, MemoryBuffer &, Buffer &); - ProcessRawFn ProcessRaw; - switch (Config.InputFormat) { - case FileFormat::Binary: - ProcessRaw = executeObjcopyOnRawBinary; - break; - case FileFormat::IHex: - ProcessRaw = executeObjcopyOnIHex; - break; - default: - ProcessRaw = nullptr; - } + auto ProcessRaw = StringSwitch<ProcessRawFn>(Config.InputFormat) + .Case("binary", executeObjcopyOnRawBinary) + .Case("ihex", executeObjcopyOnIHex) + .Default(nullptr); if (ProcessRaw) { auto BufOrErr = MemoryBuffer::getFileOrSTDIN(Config.InputFilename); |