llvm.org GIT mirror llvm / 9dc5b3e
Add new interfaces to support ldd's ReaderElf.cpp. Patch by Sid Manning! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160685 91177308-0d34-0410-b5e6-96231b3b80d8 Anshuman Dasgupta 7 years ago
1 changed file(s) with 42 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
504504 const Elf_Rela *getRela(DataRefImpl Rela) const;
505505 const char *getString(uint32_t section, uint32_t offset) const;
506506 const char *getString(const Elf_Shdr *section, uint32_t offset) const;
507 error_code getSymbolName(const Elf_Shdr *section,
508 const Elf_Sym *Symb,
509 StringRef &Res) const;
510507 error_code getSymbolVersion(const Elf_Shdr *section,
511508 const Elf_Sym *Symb,
512509 StringRef &Version,
518515 void validateSymbol(DataRefImpl Symb) const;
519516
520517 public:
518 error_code getSymbolName(const Elf_Shdr *section,
519 const Elf_Sym *Symb,
520 StringRef &Res) const;
521 error_code getSectionName(const Elf_Shdr *section,
522 StringRef &Res) const;
521523 const Elf_Dyn *getDyn(DataRefImpl DynData) const;
522524 error_code getSymbolVersion(SymbolRef Symb, StringRef &Version,
523525 bool &IsDefault) const;
596598 virtual StringRef getObjectType() const { return "ELF"; }
597599 virtual unsigned getArch() const;
598600 virtual StringRef getLoadName() const;
601 virtual error_code getSectionContents(const Elf_Shdr *sec,
602 StringRef &Res) const;
599603
600604 uint64_t getNumSections() const;
601605 uint64_t getStringTableIndex() const;
602606 ELF::Elf64_Word getSymbolTableIndex(const Elf_Sym *symb) const;
603607 const Elf_Shdr *getSection(const Elf_Sym *symb) const;
608 const Elf_Shdr *getElfSection(section_iterator &It) const;
609 const Elf_Sym *getElfSymbol(symbol_iterator &It) const;
604610
605611 // Methods for type inquiry through isa, cast, and dyn_cast
606612 bool isDyldType() const { return isDyldELFObject; }
782788 }
783789
784790 template
791 const typename ELFObjectFile::Elf_Shdr *
792 ELFObjectFile
793 ::getElfSection(section_iterator &It) const {
794 llvm::object::DataRefImpl ShdrRef = It->getRawDataRefImpl();
795 return const_cast(reinterpret_cast
796 (ShdrRef.p));
797 }
798
799 template
800 const typename ELFObjectFile::Elf_Sym *
801 ELFObjectFile
802 ::getElfSymbol(symbol_iterator &It) const {
803 return getSymbol(It->getRawDataRefImpl());
804 }
805
806 template
785807 error_code ELFObjectFile
786808 ::getSymbolFileOffset(DataRefImpl Symb,
787809 uint64_t &Result) const {
10541076 const Elf_Shdr *sec = reinterpret_cast(Sec.p);
10551077 const char *start = (const char*)base() + sec->sh_offset;
10561078 Result = StringRef(start, sec->sh_size);
1079 return object_error::success;
1080 }
1081
1082 template
1083 error_code ELFObjectFile
1084 ::getSectionContents(const Elf_Shdr *Sec,
1085 StringRef &Result) const {
1086 const char *start = (const char*)base() + Sec->sh_offset;
1087 Result = StringRef(start, Sec->sh_size);
10571088 return object_error::success;
10581089 }
10591090
21522183
21532184 template
21542185 error_code ELFObjectFile
2186 ::getSectionName(const Elf_Shdr *section,
2187 StringRef &Result) const {
2188 Result = StringRef(getString(dot_shstrtab_sec, section->sh_name));
2189 return object_error::success;
2190 }
2191
2192 template
2193 error_code ELFObjectFile
21552194 ::getSymbolVersion(const Elf_Shdr *section,
21562195 const Elf_Sym *symb,
21572196 StringRef &Version,