llvm.org GIT mirror llvm / 075618b
[yaml2obj] format some codes NFC. Summary: This line is longer than 80 characters. Subscribers: llvm-commits, jakehehrlich Differential Revision: https://reviews.llvm.org/D55419 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348578 91177308-0d34-0410-b5e6-96231b3b80d8 Xing GUO 9 months ago
1 changed file(s) with 59 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
155155 const ELFYAML::RelocationSection &Section,
156156 ContiguousBlobAccumulator &CBA);
157157 bool writeSectionContent(Elf_Shdr &SHeader, const ELFYAML::Group &Group,
158 ContiguousBlobAccumulator &CBA);
159 bool writeSectionContent(Elf_Shdr &SHeader,
160 const ELFYAML::VersionNeedSection &Section,
158161 ContiguousBlobAccumulator &CBA);
159162 bool writeSectionContent(Elf_Shdr &SHeader,
160163 const ELFYAML::MipsABIFlags &Section,
291294 // SHT_NOBITS section does not have content
292295 // so just to setup the section offset.
293296 CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);
297 } else if (auto S = dyn_cast(Sec.get())) {
298 if (S->Link.empty())
299 // For VersionNeed section set link to .dynstr by default.
300 SHeader.sh_link = getDotDynStrSecNo();
301
302 if (!writeSectionContent(SHeader, *S, CBA))
303 return false;
294304 } else
295305 llvm_unreachable("Unknown section type");
296306
547557 }
548558
549559 template
560 bool ELFState::writeSectionContent(
561 Elf_Shdr &SHeader, const ELFYAML::VersionNeedSection &Section,
562 ContiguousBlobAccumulator &CBA) {
563 assert(Section.Type == llvm::ELF::SHT_GNU_verneed &&
564 "Section type is not SHT_GNU_verneed");
565
566 typedef typename ELFT::Verneed Elf_Verneed;
567 typedef typename ELFT::Vernaux Elf_Vernaux;
568
569 uint64_t BlobSize = 0;
570 SHeader.sh_info = Section.VersionNeeds.size();
571 auto &OS = CBA.getOSAndAlignedOffset(SHeader.sh_offset, SHeader.sh_addralign);
572
573 for (auto VNeedIt = Section.VersionNeeds.begin();
574 VNeedIt != Section.VersionNeeds.end(); ++VNeedIt) {
575 Elf_Verneed VNeed;
576
577 VNeed.vn_version = VNeedIt->Version;
578 VNeed.vn_cnt = VNeedIt->Auxiliaries.size();
579 // VNeed.vn_file = DotDynstr.add(VNeedIt->File);
580 // errs() << "Need Name: " << VNeedIt->File << " Index: " << DotDynstr.add(VNeedIt->File) << '\n';
581 VNeed.vn_aux = sizeof(Elf_Verneed);
582 VNeed.vn_next =
583 (VNeedIt != Section.VersionNeeds.end() - 1)
584 ? sizeof(Elf_Verneed) + VNeed.vn_cnt * sizeof(Elf_Vernaux)
585 : 0;
586 BlobSize += sizeof(Elf_Verneed);
587 OS.write((const char *)&VNeed, sizeof(VNeed));
588
589 for (auto VNeedAuxIt = VNeedIt->Auxiliaries.begin();
590 VNeedAuxIt != VNeedIt->Auxiliaries.end(); ++VNeedAuxIt) {
591 Elf_Vernaux VNeedAux;
592 zero(VNeedAux);
593 VNeedAux.vna_hash = VNeedAuxIt->Hash;
594 VNeedAux.vna_flags = VNeedAuxIt->Flags;
595 VNeedAux.vna_other = VNeedAuxIt->Other;
596 // VNeedAux.vna_name = DotDynstr.add(VNeedAuxIt->Name);
597 VNeedAux.vna_next = (VNeedAuxIt != VNeedIt->Auxiliaries.end() - 1)
598 ? sizeof(Elf_Vernaux)
599 : 0;
600 BlobSize += sizeof(Elf_Vernaux);
601 OS.write((const char *)&VNeedAux, sizeof(Elf_Vernaux));
602 }
603 }
604 SHeader.sh_size = BlobSize;
605 return true;
606 }
607
608 template
550609 bool ELFState::writeSectionContent(Elf_Shdr &SHeader,
551610 const ELFYAML::MipsABIFlags &Section,
552611 ContiguousBlobAccumulator &CBA) {