[RuntimeDyld] Add accessors to `SectionEntry`; NFC
Summary:
Remove naked access to the data members in `SectionEntry` and route
accesses through accessor functions. This makes it obvious how the
instances of the class are used, and will also facilitate adding bounds
checking to `advanceStubOffset` in a later change.
Reviewers: lhames, loladiro, andrew.w.kaylor
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D14674
llvm-svn: 253918
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
index c0a1617..d005099 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
@@ -50,7 +50,6 @@
/// SectionEntry - represents a section emitted into memory by the dynamic
/// linker.
class SectionEntry {
-public:
/// Name - section name.
std::string Name;
@@ -74,11 +73,37 @@
/// for calculating relocations in some object formats (like MachO).
uintptr_t ObjAddress;
+public:
SectionEntry(StringRef name, uint8_t *address, size_t size,
uintptr_t objAddress)
: Name(name), Address(address), Size(size),
LoadAddress(reinterpret_cast<uintptr_t>(address)), StubOffset(size),
ObjAddress(objAddress) {}
+
+ StringRef getName() const { return Name; }
+
+ uint8_t *getAddress() const { return Address; }
+
+ /// \brief Return the address of this section with an offset.
+ uint8_t *getAddressWithOffset(unsigned OffsetBytes) const {
+ return Address + OffsetBytes;
+ }
+
+ size_t getSize() const { return Size; }
+
+ uint64_t getLoadAddress() const { return LoadAddress; }
+ void setLoadAddress(uint64_t LA) { LoadAddress = LA; }
+
+ /// \brief Return the load address of this section with an offset.
+ uint64_t getLoadAddressWithOffset(unsigned OffsetBytes) const {
+ return LoadAddress + OffsetBytes;
+ }
+
+ uintptr_t getStubOffset() const { return StubOffset; }
+
+ void advanceStubOffset(unsigned StubSize) { StubOffset += StubSize; }
+
+ uintptr_t getObjAddress() const { return ObjAddress; }
};
/// RelocationEntry - used to represent relocations internally in the dynamic
@@ -271,11 +296,11 @@
}
uint64_t getSectionLoadAddress(unsigned SectionID) const {
- return Sections[SectionID].LoadAddress;
+ return Sections[SectionID].getLoadAddress();
}
uint8_t *getSectionAddress(unsigned SectionID) const {
- return (uint8_t *)Sections[SectionID].Address;
+ return Sections[SectionID].getAddress();
}
void writeInt16BE(uint8_t *Addr, uint16_t Value) {