summaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2012-03-20 22:25:39 +0000
committerSean Callanan <scallanan@apple.com>2012-03-20 22:25:39 +0000
commit5069b21b45d8ec99a1b34b6483d800ba5c2ea598 (patch)
tree3cf1b418721fc326d8e42f0db32e6e8d23ee5593 /lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
parent768b4e8cb4dabc14b8e16806d1defb79f83a7d72 (diff)
downloadllvm-5069b21b45d8ec99a1b34b6483d800ba5c2ea598.tar.gz
llvm-5069b21b45d8ec99a1b34b6483d800ba5c2ea598.tar.bz2
llvm-5069b21b45d8ec99a1b34b6483d800ba5c2ea598.tar.xz
RuntimeDyldMachO has the ability to keep track of
relocations (i.e., pieces of data whose addresses are referred to elsewhere in the binary image) and update the references when the section containing the relocations moves. The way this works is that there is a map from section IDs to lists of relocations. Because the relocations are associated with the section containing the data being referred to, they are updated only when the target moves. However, many data references are relative and also depend on the location of the referrer. To solve this problem, I introduced a new data structure, Referrer, which simply contains the section being referred to and the index of the relocation in that section. These referrers are associated with the source containing the reference that needs to be updated, so now regardless of which end of the relocation moves, the relocation will now be updated correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153147 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h')
-rw-r--r--lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
index 09803cff74..6721703565 100644
--- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
+++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
@@ -43,10 +43,26 @@ class RuntimeDyldMachO : public RuntimeDyldImpl {
: SectionID(id), Offset(offset), Data(data), Addend(addend) {}
};
typedef SmallVector<RelocationEntry, 4> RelocationList;
+
+ // For each section, keep a list of referrers in that section that are clients
+ // of relocations in other sections. Whenever a relocation gets created,
+ // create a corresponding referrer. Whenever relocations are re-resolved,
+ // re-resolve the referrers' relocations as well.
+ struct Referrer {
+ unsigned SectionID; // Section whose RelocationList contains the relocation.
+ uint32_t Index; // Index of the RelocatonEntry in that RelocationList.
+
+ Referrer(unsigned id, uint32_t index)
+ : SectionID(id), Index(index) {}
+ };
+ typedef SmallVector<Referrer, 4> ReferrerList;
+
// Relocations to sections already loaded. Indexed by SectionID which is the
// source of the address. The target where the address will be writen is
// SectionID/Offset in the relocation itself.
IndexedMap<RelocationList> Relocations;
+ // Referrers corresponding to Relocations.
+ IndexedMap<ReferrerList> Referrers;
// Relocations to symbols that are not yet resolved. Must be external
// relocations by definition. Indexed by symbol name.
StringMap<RelocationList> UnresolvedRelocations;