From: George Rimar Date: Wed, 24 Apr 2019 13:02:15 +0000 (+0000) Subject: [yaml2elf] - Replace a loop with write_zeros(). NFC. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=37c286fa0b4ab98a1e93157ba909793f0b728fe4;p=llvm [yaml2elf] - Replace a loop with write_zeros(). NFC. And apply clang-format to the method changed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359090 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/yaml2obj/yaml2elf.cpp b/tools/yaml2obj/yaml2elf.cpp index a30093a042f..974acbd40c9 100644 --- a/tools/yaml2obj/yaml2elf.cpp +++ b/tools/yaml2obj/yaml2elf.cpp @@ -503,17 +503,16 @@ void ELFState::addSymbols(ArrayRef Symbols, } template -void -ELFState::writeSectionContent(Elf_Shdr &SHeader, - const ELFYAML::RawContentSection &Section, - ContiguousBlobAccumulator &CBA) { +void ELFState::writeSectionContent( + Elf_Shdr &SHeader, const ELFYAML::RawContentSection &Section, + ContiguousBlobAccumulator &CBA) { assert(Section.Size >= Section.Content.binary_size() && "Section size and section content are inconsistent"); raw_ostream &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign); Section.Content.writeAsBinary(OS); - for (auto i = Section.Content.binary_size(); i < Section.Size; ++i) - OS.write(0); + OS.write_zeros(Section.Size - Section.Content.binary_size()); + if (Section.EntSize) SHeader.sh_entsize = *Section.EntSize; else if (Section.Type == llvm::ELF::SHT_RELR)