/// SectionEntry - represents a section emitted into memory by the dynamic
/// linker.
class SectionEntry {
-public:
/// Name - section name.
std::string Name;
/// 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
}
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) {