aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Object
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2011-10-25 20:35:53 +0000
committerOwen Anderson <resistor@mac.com>2011-10-25 20:35:53 +0000
commit0685e94895f26f96aa1032696e3150dd00aad1f3 (patch)
treef6d9ff1ff353c7f88f0b43b0461338e50d19fcc6 /lib/Object
parentf62333df5e31843178678a6aad6e0d9bbe16c283 (diff)
downloadexternal_llvm-0685e94895f26f96aa1032696e3150dd00aad1f3.zip
external_llvm-0685e94895f26f96aa1032696e3150dd00aad1f3.tar.gz
external_llvm-0685e94895f26f96aa1032696e3150dd00aad1f3.tar.bz2
Add support for the notion of "hidden" relocations. On MachO, these are relocation entries that are used as additional information for other, real relocations, rather than being relocations themselves.
I'm not familiar enough with ELF or COFF to know if they should have any relocations marked hidden. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142961 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object')
-rw-r--r--lib/Object/MachOObjectFile.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp
index 96db34f..a4d7cb5 100644
--- a/lib/Object/MachOObjectFile.cpp
+++ b/lib/Object/MachOObjectFile.cpp
@@ -952,6 +952,38 @@ error_code MachOObjectFile::getRelocationValueString(DataRefImpl Rel,
return object_error::success;
}
+error_code MachOObjectFile::getRelocationHidden(DataRefImpl Rel,
+ bool &Result) const {
+ InMemoryStruct<macho::RelocationEntry> RE;
+ getRelocation(Rel, RE);
+
+ unsigned Type = (RE->Word1 >> 28) & 0xF;
+ unsigned Arch = getArch();
+
+ Result = false;
+
+ // On arches that use the generic relocations, GENERIC_RELOC_PAIR
+ // is always hidden.
+ if (Arch == Triple::x86 || Arch == Triple::arm) {
+ if (Type == 1) Result = true;
+ } else if (Arch == Triple::x86_64) {
+ // On x86_64, X86_64_RELOC_UNSIGNED is hidden only when it follows
+ // an X864_64_RELOC_SUBTRACTOR.
+ if (Type == 0 && Rel.d.a > 0) {
+ DataRefImpl RelPrev = Rel;
+ RelPrev.d.a--;
+ InMemoryStruct<macho::RelocationEntry> REPrev;
+ getRelocation(RelPrev, REPrev);
+
+ unsigned PrevType = (REPrev->Word1 >> 28) & 0xF;
+
+ if (PrevType == 5) Result = true;
+ }
+ }
+
+ return object_error::success;
+}
+
/*===-- Miscellaneous -----------------------------------------------------===*/
uint8_t MachOObjectFile::getBytesInAddress() const {