Skip to content

Commit c76671b

Browse files
committed
[llvm-objcopy] Remove unneeded checks. NFC
Differential revision: https://reviews.llvm.org/D59081 llvm-svn: 355914
1 parent d3a8fd8 commit c76671b

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -520,35 +520,31 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj,
520520
}
521521
}
522522
}
523-
524-
if (!Config.AddSection.empty()) {
525-
for (const auto &Flag : Config.AddSection) {
526-
std::pair<StringRef, StringRef> SecPair = Flag.split("=");
527-
StringRef SecName = SecPair.first;
528-
StringRef File = SecPair.second;
529-
ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr =
530-
MemoryBuffer::getFile(File);
531-
if (!BufOrErr)
532-
return createFileError(File, errorCodeToError(BufOrErr.getError()));
533-
std::unique_ptr<MemoryBuffer> Buf = std::move(*BufOrErr);
534-
ArrayRef<uint8_t> Data(
535-
reinterpret_cast<const uint8_t *>(Buf->getBufferStart()),
536-
Buf->getBufferSize());
537-
OwnedDataSection &NewSection =
538-
Obj.addSection<OwnedDataSection>(SecName, Data);
539-
if (SecName.startswith(".note") && SecName != ".note.GNU-stack")
540-
NewSection.Type = SHT_NOTE;
541-
}
523+
524+
for (const auto &Flag : Config.AddSection) {
525+
std::pair<StringRef, StringRef> SecPair = Flag.split("=");
526+
StringRef SecName = SecPair.first;
527+
StringRef File = SecPair.second;
528+
ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr =
529+
MemoryBuffer::getFile(File);
530+
if (!BufOrErr)
531+
return createFileError(File, errorCodeToError(BufOrErr.getError()));
532+
std::unique_ptr<MemoryBuffer> Buf = std::move(*BufOrErr);
533+
ArrayRef<uint8_t> Data(
534+
reinterpret_cast<const uint8_t *>(Buf->getBufferStart()),
535+
Buf->getBufferSize());
536+
OwnedDataSection &NewSection =
537+
Obj.addSection<OwnedDataSection>(SecName, Data);
538+
if (SecName.startswith(".note") && SecName != ".note.GNU-stack")
539+
NewSection.Type = SHT_NOTE;
542540
}
543541

544-
if (!Config.DumpSection.empty()) {
545-
for (const auto &Flag : Config.DumpSection) {
546-
std::pair<StringRef, StringRef> SecPair = Flag.split("=");
547-
StringRef SecName = SecPair.first;
548-
StringRef File = SecPair.second;
549-
if (Error E = dumpSectionToFile(SecName, File, Obj))
550-
return createFileError(Config.InputFilename, std::move(E));
551-
}
542+
for (const auto &Flag : Config.DumpSection) {
543+
std::pair<StringRef, StringRef> SecPair = Flag.split("=");
544+
StringRef SecName = SecPair.first;
545+
StringRef File = SecPair.second;
546+
if (Error E = dumpSectionToFile(SecName, File, Obj))
547+
return createFileError(Config.InputFilename, std::move(E));
552548
}
553549

554550
if (!Config.AddGnuDebugLink.empty())

0 commit comments

Comments
 (0)