From c3ad5d9485d0f5c5be024a963f3e84ece7185cb4 Mon Sep 17 00:00:00 2001 From: Eugene Leviant Date: Tue, 12 Mar 2019 12:41:06 +0000 Subject: [PATCH] [llvm-objcopy] Remove unneeded checks. NFC Differential revision: https://reviews.llvm.org/D59081 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355914 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-objcopy/ELF/ELFObjcopy.cpp | 50 ++++++++++++--------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/tools/llvm-objcopy/ELF/ELFObjcopy.cpp b/tools/llvm-objcopy/ELF/ELFObjcopy.cpp index 83f1f0e4743..cbf6a3d2777 100644 --- a/tools/llvm-objcopy/ELF/ELFObjcopy.cpp +++ b/tools/llvm-objcopy/ELF/ELFObjcopy.cpp @@ -520,35 +520,31 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj, } } } - - if (!Config.AddSection.empty()) { - for (const auto &Flag : Config.AddSection) { - std::pair SecPair = Flag.split("="); - StringRef SecName = SecPair.first; - StringRef File = SecPair.second; - ErrorOr> BufOrErr = - MemoryBuffer::getFile(File); - if (!BufOrErr) - return createFileError(File, errorCodeToError(BufOrErr.getError())); - std::unique_ptr Buf = std::move(*BufOrErr); - ArrayRef Data( - reinterpret_cast(Buf->getBufferStart()), - Buf->getBufferSize()); - OwnedDataSection &NewSection = - Obj.addSection(SecName, Data); - if (SecName.startswith(".note") && SecName != ".note.GNU-stack") - NewSection.Type = SHT_NOTE; - } + + for (const auto &Flag : Config.AddSection) { + std::pair SecPair = Flag.split("="); + StringRef SecName = SecPair.first; + StringRef File = SecPair.second; + ErrorOr> BufOrErr = + MemoryBuffer::getFile(File); + if (!BufOrErr) + return createFileError(File, errorCodeToError(BufOrErr.getError())); + std::unique_ptr Buf = std::move(*BufOrErr); + ArrayRef Data( + reinterpret_cast(Buf->getBufferStart()), + Buf->getBufferSize()); + OwnedDataSection &NewSection = + Obj.addSection(SecName, Data); + if (SecName.startswith(".note") && SecName != ".note.GNU-stack") + NewSection.Type = SHT_NOTE; } - if (!Config.DumpSection.empty()) { - for (const auto &Flag : Config.DumpSection) { - std::pair SecPair = Flag.split("="); - StringRef SecName = SecPair.first; - StringRef File = SecPair.second; - if (Error E = dumpSectionToFile(SecName, File, Obj)) - return createFileError(Config.InputFilename, std::move(E)); - } + for (const auto &Flag : Config.DumpSection) { + std::pair SecPair = Flag.split("="); + StringRef SecName = SecPair.first; + StringRef File = SecPair.second; + if (Error E = dumpSectionToFile(SecName, File, Obj)) + return createFileError(Config.InputFilename, std::move(E)); } if (!Config.AddGnuDebugLink.empty()) -- 2.40.0