[PATCH] D26074: [ELF] Add getOffset to ELFSectionRef and enable LLVM casting for it
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 28 07:59:01 PDT 2016
evgeny777 created this revision.
evgeny777 added reviewers: rafael, hans, grimar.
evgeny777 added subscribers: ikudrin, llvm-commits.
evgeny777 set the repository for this revision to rL LLVM.
evgeny777 added a project: lld.
Required for https://reviews.llvm.org/D26070
Repository:
rL LLVM
https://reviews.llvm.org/D26074
Files:
include/llvm/Object/ELFObjectFile.h
Index: include/llvm/Object/ELFObjectFile.h
===================================================================
--- include/llvm/Object/ELFObjectFile.h
+++ include/llvm/Object/ELFObjectFile.h
@@ -59,6 +59,7 @@
virtual uint32_t getSectionType(DataRefImpl Sec) const = 0;
virtual uint64_t getSectionFlags(DataRefImpl Sec) const = 0;
+ virtual uint64_t getSectionOffset(DataRefImpl Sec) const = 0;
virtual ErrorOr<int64_t> getRelocationAddend(DataRefImpl Rel) const = 0;
@@ -90,6 +91,14 @@
uint64_t getFlags() const {
return getObject()->getSectionFlags(getRawDataRefImpl());
}
+
+ uint64_t getOffset() const {
+ return getObject()->getSectionOffset(getRawDataRefImpl());
+ }
+
+ static inline bool classof(const SectionRef *v) {
+ return v->getObject()->isELF();
+ }
};
class elf_section_iterator : public section_iterator {
@@ -245,6 +254,7 @@
uint32_t getSectionType(DataRefImpl Sec) const override;
uint64_t getSectionFlags(DataRefImpl Sec) const override;
+ uint64_t getSectionOffset(DataRefImpl Sec) const override;
StringRef getRelocationTypeName(uint32_t Type) const;
/// \brief Get the relocation section that contains \a Rel.
@@ -381,6 +391,11 @@
}
template <class ELFT>
+uint64_t ELFObjectFile<ELFT>::getSectionOffset(DataRefImpl Sec) const {
+ return getSection(Sec)->sh_offset;
+}
+
+template <class ELFT>
uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
const Elf_Sym *ESym = getSymbol(Symb);
uint64_t Ret = ESym->st_value;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26074.76191.patch
Type: text/x-patch
Size: 1530 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161028/f31a73df/attachment.bin>
More information about the llvm-commits
mailing list