llvm.org GIT mirror llvm / 47b7f78
rename toELFShdrIter to getSection and move it closer to getSymbol. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244483 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 4 years ago
1 changed file(s) with 17 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
302302 return EF.template getEntry(Sym.d.a, Sym.d.b);
303303 }
304304
305 const Elf_Shdr *getSection(DataRefImpl Sec) const {
306 return reinterpret_cast(Sec.p);
307 }
308
305309 basic_symbol_iterator symbol_begin_impl() const override;
306310 basic_symbol_iterator symbol_end_impl() const override;
307311
356360
357361 template
358362 uint64_t ELFObjectFile::getSectionFlags(DataRefImpl Sec) const {
359 return toELFShdrIter(Sec)->sh_flags;
363 return getSection(Sec)->sh_flags;
360364 }
361365
362366 template
363367 uint32_t ELFObjectFile::getSectionType(DataRefImpl Sec) const {
364 return toELFShdrIter(Sec)->sh_type;
368 return getSection(Sec)->sh_type;
365369 }
366370
367371 template
524528
525529 template
526530 void ELFObjectFile::moveSectionNext(DataRefImpl &Sec) const {
527 const Elf_Shdr *ESec = toELFShdrIter(Sec);
531 const Elf_Shdr *ESec = getSection(Sec);
528532 Sec = toDRI(++ESec);
529533 }
530534
531535 template
532536 std::error_code ELFObjectFile::getSectionName(DataRefImpl Sec,
533537 StringRef &Result) const {
534 ErrorOr Name = EF.getSectionName(&*toELFShdrIter(Sec));
538 ErrorOr Name = EF.getSectionName(&*getSection(Sec));
535539 if (!Name)
536540 return Name.getError();
537541 Result = *Name;
540544
541545 template
542546 uint64_t ELFObjectFile::getSectionAddress(DataRefImpl Sec) const {
543 return toELFShdrIter(Sec)->sh_addr;
547 return getSection(Sec)->sh_addr;
544548 }
545549
546550 template
547551 uint64_t ELFObjectFile::getSectionSize(DataRefImpl Sec) const {
548 return toELFShdrIter(Sec)->sh_size;
552 return getSection(Sec)->sh_size;
549553 }
550554
551555 template
552556 std::error_code
553557 ELFObjectFile::getSectionContents(DataRefImpl Sec,
554558 StringRef &Result) const {
555 const Elf_Shdr *EShdr = toELFShdrIter(Sec);
559 const Elf_Shdr *EShdr = getSection(Sec);
556560 Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
557561 return std::error_code();
558562 }
559563
560564 template
561565 uint64_t ELFObjectFile::getSectionAlignment(DataRefImpl Sec) const {
562 return toELFShdrIter(Sec)->sh_addralign;
566 return getSection(Sec)->sh_addralign;
563567 }
564568
565569 template
566570 bool ELFObjectFile::isSectionText(DataRefImpl Sec) const {
567 return toELFShdrIter(Sec)->sh_flags & ELF::SHF_EXECINSTR;
571 return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR;
568572 }
569573
570574 template
571575 bool ELFObjectFile::isSectionData(DataRefImpl Sec) const {
572 const Elf_Shdr *EShdr = toELFShdrIter(Sec);
576 const Elf_Shdr *EShdr = getSection(Sec);
573577 return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
574578 EShdr->sh_type == ELF::SHT_PROGBITS;
575579 }
576580
577581 template
578582 bool ELFObjectFile::isSectionBSS(DataRefImpl Sec) const {
579 const Elf_Shdr *EShdr = toELFShdrIter(Sec);
583 const Elf_Shdr *EShdr = getSection(Sec);
580584 return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
581585 EShdr->sh_type == ELF::SHT_NOBITS;
582586 }
583587
584588 template
585589 bool ELFObjectFile::isSectionVirtual(DataRefImpl Sec) const {
586 return toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS;
590 return getSection(Sec)->sh_type == ELF::SHT_NOBITS;
587591 }
588592
589593 template
630634 if (EF.getHeader()->e_type != ELF::ET_REL)
631635 return section_end();
632636
633 const Elf_Shdr *EShdr = toELFShdrIter(Sec);
637 const Elf_Shdr *EShdr = getSection(Sec);
634638 uintX_t Type = EShdr->sh_type;
635639 if (Type != ELF::SHT_REL && Type != ELF::SHT_RELA)
636640 return section_end();