| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 1 | //===----- RuntimeDyldMachOARM.h ---- MachO/ARM specific code. ----*- C++ -*-=// | 
|  | 2 | // | 
|  | 3 | //                     The LLVM Compiler Infrastructure | 
|  | 4 | // | 
|  | 5 | // This file is distributed under the University of Illinois Open Source | 
|  | 6 | // License. See LICENSE.TXT for details. | 
|  | 7 | // | 
|  | 8 | //===----------------------------------------------------------------------===// | 
|  | 9 |  | 
| Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDMACHOARM_H | 
|  | 11 | #define LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDMACHOARM_H | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 12 |  | 
|  | 13 | #include "../RuntimeDyldMachO.h" | 
|  | 14 |  | 
|  | 15 | #define DEBUG_TYPE "dyld" | 
|  | 16 |  | 
|  | 17 | namespace llvm { | 
|  | 18 |  | 
|  | 19 | class RuntimeDyldMachOARM | 
|  | 20 | : public RuntimeDyldMachOCRTPBase<RuntimeDyldMachOARM> { | 
| Lang Hames | 1316365 | 2014-07-30 03:35:05 +0000 | [diff] [blame] | 21 | private: | 
|  | 22 | typedef RuntimeDyldMachOCRTPBase<RuntimeDyldMachOARM> ParentT; | 
|  | 23 |  | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 24 | public: | 
| Lang Hames | eb195f0 | 2014-09-04 04:53:03 +0000 | [diff] [blame] | 25 |  | 
|  | 26 | typedef uint32_t TargetPtrT; | 
|  | 27 |  | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 28 | RuntimeDyldMachOARM(RTDyldMemoryManager *MM) : RuntimeDyldMachOCRTPBase(MM) {} | 
|  | 29 |  | 
|  | 30 | unsigned getMaxStubSize() override { return 8; } | 
|  | 31 |  | 
| Lang Hames | e5fc826 | 2014-07-17 23:11:30 +0000 | [diff] [blame] | 32 | unsigned getStubAlignment() override { return 4; } | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 33 |  | 
| Lang Hames | 25d9309 | 2014-08-08 23:12:22 +0000 | [diff] [blame] | 34 | int64_t decodeAddend(const RelocationEntry &RE) const { | 
|  | 35 | const SectionEntry &Section = Sections[RE.SectionID]; | 
|  | 36 | uint8_t *LocalAddress = Section.Address + RE.Offset; | 
|  | 37 |  | 
|  | 38 | switch (RE.RelType) { | 
| Lang Hames | 1316365 | 2014-07-30 03:35:05 +0000 | [diff] [blame] | 39 | default: | 
| Lang Hames | 25d9309 | 2014-08-08 23:12:22 +0000 | [diff] [blame] | 40 | return memcpyAddend(RE); | 
| Lang Hames | 1316365 | 2014-07-30 03:35:05 +0000 | [diff] [blame] | 41 | case MachO::ARM_RELOC_BR24: { | 
| Daniel Sanders | 66e799f | 2014-11-06 09:53:05 +0000 | [diff] [blame] | 42 | uint32_t Temp = readBytesUnaligned(LocalAddress, 4); | 
| Lang Hames | 1316365 | 2014-07-30 03:35:05 +0000 | [diff] [blame] | 43 | Temp &= 0x00ffffff; // Mask out the opcode. | 
|  | 44 | // Now we've got the shifted immediate, shift by 2, sign extend and ret. | 
|  | 45 | return SignExtend32<26>(Temp << 2); | 
|  | 46 | } | 
|  | 47 | } | 
|  | 48 | } | 
|  | 49 |  | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 50 | relocation_iterator | 
|  | 51 | processRelocationRef(unsigned SectionID, relocation_iterator RelI, | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 52 | const ObjectFile &BaseObjT, | 
|  | 53 | ObjSectionToIDMap &ObjSectionToID, | 
| Lang Hames | a5cd950 | 2014-11-27 05:40:13 +0000 | [diff] [blame^] | 54 | StubMap &Stubs) override { | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 55 | const MachOObjectFile &Obj = | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 56 | static_cast<const MachOObjectFile &>(BaseObjT); | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 57 | MachO::any_relocation_info RelInfo = | 
|  | 58 | Obj.getRelocation(RelI->getRawDataRefImpl()); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 59 | uint32_t RelType = Obj.getAnyRelocationType(RelInfo); | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 60 |  | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 61 | if (Obj.isRelocationScattered(RelInfo)) { | 
|  | 62 | if (RelType == MachO::ARM_RELOC_HALF_SECTDIFF) | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 63 | return processHALFSECTDIFFRelocation(SectionID, RelI, Obj, | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 64 | ObjSectionToID); | 
|  | 65 | else | 
|  | 66 | return ++++RelI; | 
|  | 67 | } | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 68 |  | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 69 | RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI)); | 
| Lang Hames | 25d9309 | 2014-08-08 23:12:22 +0000 | [diff] [blame] | 70 | RE.Addend = decodeAddend(RE); | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 71 | RelocationValueRef Value( | 
| Lang Hames | a5cd950 | 2014-11-27 05:40:13 +0000 | [diff] [blame^] | 72 | getRelocationValueRef(Obj, RelI, RE, ObjSectionToID)); | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 73 |  | 
| Lang Hames | 1316365 | 2014-07-30 03:35:05 +0000 | [diff] [blame] | 74 | if (RE.IsPCRel) | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 75 | makeValueAddendPCRel(Value, Obj, RelI, 8); | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 76 |  | 
|  | 77 | if ((RE.RelType & 0xf) == MachO::ARM_RELOC_BR24) | 
|  | 78 | processBranchRelocation(RE, Value, Stubs); | 
|  | 79 | else { | 
| Lang Hames | ca279c2 | 2014-09-07 04:03:32 +0000 | [diff] [blame] | 80 | RE.Addend = Value.Offset; | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 81 | if (Value.SymbolName) | 
|  | 82 | addRelocationForSymbol(RE, Value.SymbolName); | 
|  | 83 | else | 
|  | 84 | addRelocationForSection(RE, Value.SectionID); | 
|  | 85 | } | 
|  | 86 |  | 
|  | 87 | return ++RelI; | 
|  | 88 | } | 
|  | 89 |  | 
| Benjamin Kramer | 8c90fd7 | 2014-09-03 11:41:21 +0000 | [diff] [blame] | 90 | void resolveRelocation(const RelocationEntry &RE, uint64_t Value) override { | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 91 | DEBUG(dumpRelocationToResolve(RE, Value)); | 
|  | 92 | const SectionEntry &Section = Sections[RE.SectionID]; | 
|  | 93 | uint8_t *LocalAddress = Section.Address + RE.Offset; | 
|  | 94 |  | 
|  | 95 | // If the relocation is PC-relative, the value to be encoded is the | 
|  | 96 | // pointer difference. | 
|  | 97 | if (RE.IsPCRel) { | 
|  | 98 | uint64_t FinalAddress = Section.LoadAddress + RE.Offset; | 
|  | 99 | Value -= FinalAddress; | 
|  | 100 | // ARM PCRel relocations have an effective-PC offset of two instructions | 
|  | 101 | // (four bytes in Thumb mode, 8 bytes in ARM mode). | 
|  | 102 | // FIXME: For now, assume ARM mode. | 
|  | 103 | Value -= 8; | 
|  | 104 | } | 
|  | 105 |  | 
|  | 106 | switch (RE.RelType) { | 
|  | 107 | default: | 
|  | 108 | llvm_unreachable("Invalid relocation type!"); | 
|  | 109 | case MachO::ARM_RELOC_VANILLA: | 
| Lang Hames | 4669cd0 | 2014-09-11 17:27:01 +0000 | [diff] [blame] | 110 | writeBytesUnaligned(Value + RE.Addend, LocalAddress, 1 << RE.Size); | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 111 | break; | 
|  | 112 | case MachO::ARM_RELOC_BR24: { | 
|  | 113 | // Mask the value into the target address. We know instructions are | 
|  | 114 | // 32-bit aligned, so we can do it all at once. | 
| Lang Hames | 4669cd0 | 2014-09-11 17:27:01 +0000 | [diff] [blame] | 115 | Value += RE.Addend; | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 116 | // The low two bits of the value are not encoded. | 
|  | 117 | Value >>= 2; | 
|  | 118 | // Mask the value to 24 bits. | 
|  | 119 | uint64_t FinalValue = Value & 0xffffff; | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 120 | // FIXME: If the destination is a Thumb function (and the instruction | 
|  | 121 | // is a non-predicated BL instruction), we need to change it to a BLX | 
|  | 122 | // instruction instead. | 
|  | 123 |  | 
|  | 124 | // Insert the value into the instruction. | 
| Daniel Sanders | 66e799f | 2014-11-06 09:53:05 +0000 | [diff] [blame] | 125 | uint32_t Temp = readBytesUnaligned(LocalAddress, 4); | 
|  | 126 | writeBytesUnaligned((Temp & ~0xffffff) | FinalValue, LocalAddress, 4); | 
|  | 127 |  | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 128 | break; | 
|  | 129 | } | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 130 | case MachO::ARM_RELOC_HALF_SECTDIFF: { | 
|  | 131 | uint64_t SectionABase = Sections[RE.Sections.SectionA].LoadAddress; | 
|  | 132 | uint64_t SectionBBase = Sections[RE.Sections.SectionB].LoadAddress; | 
|  | 133 | assert((Value == SectionABase || Value == SectionBBase) && | 
|  | 134 | "Unexpected HALFSECTDIFF relocation value."); | 
|  | 135 | Value = SectionABase - SectionBBase + RE.Addend; | 
|  | 136 | if (RE.Size & 0x1) // :upper16: | 
|  | 137 | Value = (Value >> 16); | 
|  | 138 | Value &= 0xffff; | 
|  | 139 |  | 
| Daniel Sanders | 66e799f | 2014-11-06 09:53:05 +0000 | [diff] [blame] | 140 | uint32_t Insn = readBytesUnaligned(LocalAddress, 4); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 141 | Insn = (Insn & 0xfff0f000) | ((Value & 0xf000) << 4) | (Value & 0x0fff); | 
| Daniel Sanders | 66e799f | 2014-11-06 09:53:05 +0000 | [diff] [blame] | 142 | writeBytesUnaligned(Insn, LocalAddress, 4); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 143 | break; | 
|  | 144 | } | 
|  | 145 |  | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 146 | case MachO::ARM_THUMB_RELOC_BR22: | 
|  | 147 | case MachO::ARM_THUMB_32BIT_BRANCH: | 
|  | 148 | case MachO::ARM_RELOC_HALF: | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 149 | case MachO::ARM_RELOC_PAIR: | 
|  | 150 | case MachO::ARM_RELOC_SECTDIFF: | 
|  | 151 | case MachO::ARM_RELOC_LOCAL_SECTDIFF: | 
|  | 152 | case MachO::ARM_RELOC_PB_LA_PTR: | 
|  | 153 | Error("Relocation type not implemented yet!"); | 
|  | 154 | return; | 
|  | 155 | } | 
|  | 156 | } | 
|  | 157 |  | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 158 | void finalizeSection(const ObjectFile &Obj, unsigned SectionID, | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 159 | const SectionRef &Section) { | 
|  | 160 | StringRef Name; | 
|  | 161 | Section.getName(Name); | 
|  | 162 |  | 
|  | 163 | if (Name == "__nl_symbol_ptr") | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 164 | populateIndirectSymbolPointersSection(cast<MachOObjectFile>(Obj), | 
|  | 165 | Section, SectionID); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 166 | } | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 167 |  | 
|  | 168 | private: | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 169 |  | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 170 | void processBranchRelocation(const RelocationEntry &RE, | 
|  | 171 | const RelocationValueRef &Value, | 
|  | 172 | StubMap &Stubs) { | 
|  | 173 | // This is an ARM branch relocation, need to use a stub function. | 
|  | 174 | // Look up for existing stub. | 
|  | 175 | SectionEntry &Section = Sections[RE.SectionID]; | 
|  | 176 | RuntimeDyldMachO::StubMap::const_iterator i = Stubs.find(Value); | 
|  | 177 | uint8_t *Addr; | 
|  | 178 | if (i != Stubs.end()) { | 
|  | 179 | Addr = Section.Address + i->second; | 
|  | 180 | } else { | 
|  | 181 | // Create a new stub function. | 
|  | 182 | Stubs[Value] = Section.StubOffset; | 
|  | 183 | uint8_t *StubTargetAddr = | 
|  | 184 | createStubFunction(Section.Address + Section.StubOffset); | 
|  | 185 | RelocationEntry StubRE(RE.SectionID, StubTargetAddr - Section.Address, | 
| Lang Hames | ca279c2 | 2014-09-07 04:03:32 +0000 | [diff] [blame] | 186 | MachO::GENERIC_RELOC_VANILLA, Value.Offset, false, | 
| Lang Hames | 1316365 | 2014-07-30 03:35:05 +0000 | [diff] [blame] | 187 | 2); | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 188 | if (Value.SymbolName) | 
|  | 189 | addRelocationForSymbol(StubRE, Value.SymbolName); | 
|  | 190 | else | 
|  | 191 | addRelocationForSection(StubRE, Value.SectionID); | 
|  | 192 | Addr = Section.Address + Section.StubOffset; | 
|  | 193 | Section.StubOffset += getMaxStubSize(); | 
|  | 194 | } | 
| Lang Hames | 1316365 | 2014-07-30 03:35:05 +0000 | [diff] [blame] | 195 | RelocationEntry TargetRE(RE.SectionID, RE.Offset, RE.RelType, 0, | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 196 | RE.IsPCRel, RE.Size); | 
|  | 197 | resolveRelocation(TargetRE, (uint64_t)Addr); | 
|  | 198 | } | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 199 |  | 
|  | 200 | relocation_iterator | 
|  | 201 | processHALFSECTDIFFRelocation(unsigned SectionID, relocation_iterator RelI, | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 202 | const ObjectFile &BaseTObj, | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 203 | ObjSectionToIDMap &ObjSectionToID) { | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 204 | const MachOObjectFile &MachO = | 
|  | 205 | static_cast<const MachOObjectFile&>(BaseTObj); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 206 | MachO::any_relocation_info RE = | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 207 | MachO.getRelocation(RelI->getRawDataRefImpl()); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 208 |  | 
|  | 209 |  | 
|  | 210 | // For a half-diff relocation the length bits actually record whether this | 
|  | 211 | // is a movw/movt, and whether this is arm or thumb. | 
|  | 212 | // Bit 0 indicates movw (b0 == 0) or movt (b0 == 1). | 
|  | 213 | // Bit 1 indicates arm (b1 == 0) or thumb (b1 == 1). | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 214 | unsigned HalfDiffKindBits = MachO.getAnyRelocationLength(RE); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 215 | if (HalfDiffKindBits & 0x2) | 
|  | 216 | llvm_unreachable("Thumb not yet supported."); | 
|  | 217 |  | 
|  | 218 | SectionEntry &Section = Sections[SectionID]; | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 219 | uint32_t RelocType = MachO.getAnyRelocationType(RE); | 
|  | 220 | bool IsPCRel = MachO.getAnyRelocationPCRel(RE); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 221 | uint64_t Offset; | 
|  | 222 | RelI->getOffset(Offset); | 
|  | 223 | uint8_t *LocalAddress = Section.Address + Offset; | 
| Daniel Sanders | 66e799f | 2014-11-06 09:53:05 +0000 | [diff] [blame] | 224 | int64_t Immediate = readBytesUnaligned(LocalAddress, 4); // Copy the whole instruction out. | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 225 | Immediate = ((Immediate >> 4) & 0xf000) | (Immediate & 0xfff); | 
|  | 226 |  | 
|  | 227 | ++RelI; | 
|  | 228 | MachO::any_relocation_info RE2 = | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 229 | MachO.getRelocation(RelI->getRawDataRefImpl()); | 
|  | 230 | uint32_t AddrA = MachO.getScatteredRelocationValue(RE); | 
|  | 231 | section_iterator SAI = getSectionByAddress(MachO, AddrA); | 
|  | 232 | assert(SAI != MachO.section_end() && "Can't find section for address A"); | 
| Rafael Espindola | 8029127 | 2014-10-08 15:28:58 +0000 | [diff] [blame] | 233 | uint64_t SectionABase = SAI->getAddress(); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 234 | uint64_t SectionAOffset = AddrA - SectionABase; | 
|  | 235 | SectionRef SectionA = *SAI; | 
| Rafael Espindola | 8029127 | 2014-10-08 15:28:58 +0000 | [diff] [blame] | 236 | bool IsCode = SectionA.isText(); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 237 | uint32_t SectionAID = | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 238 | findOrEmitSection(MachO, SectionA, IsCode, ObjSectionToID); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 239 |  | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 240 | uint32_t AddrB = MachO.getScatteredRelocationValue(RE2); | 
|  | 241 | section_iterator SBI = getSectionByAddress(MachO, AddrB); | 
|  | 242 | assert(SBI != MachO.section_end() && "Can't find section for address B"); | 
| Rafael Espindola | 8029127 | 2014-10-08 15:28:58 +0000 | [diff] [blame] | 243 | uint64_t SectionBBase = SBI->getAddress(); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 244 | uint64_t SectionBOffset = AddrB - SectionBBase; | 
|  | 245 | SectionRef SectionB = *SBI; | 
|  | 246 | uint32_t SectionBID = | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 247 | findOrEmitSection(MachO, SectionB, IsCode, ObjSectionToID); | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 248 |  | 
| Lang Hames | b5c7b1f | 2014-11-26 16:54:40 +0000 | [diff] [blame] | 249 | uint32_t OtherHalf = MachO.getAnyRelocationAddress(RE2) & 0xffff; | 
| Lang Hames | 6f1048f | 2014-09-11 19:21:14 +0000 | [diff] [blame] | 250 | unsigned Shift = (HalfDiffKindBits & 0x1) ? 16 : 0; | 
|  | 251 | uint32_t FullImmVal = (Immediate << Shift) | (OtherHalf << (16 - Shift)); | 
|  | 252 | int64_t Addend = FullImmVal - (AddrA - AddrB); | 
|  | 253 |  | 
|  | 254 | // addend = Encoded - Expected | 
|  | 255 | //        = Encoded - (AddrA - AddrB) | 
|  | 256 |  | 
|  | 257 | DEBUG(dbgs() << "Found SECTDIFF: AddrA: " << AddrA << ", AddrB: " << AddrB | 
|  | 258 | << ", Addend: " << Addend << ", SectionA ID: " << SectionAID | 
|  | 259 | << ", SectionAOffset: " << SectionAOffset | 
|  | 260 | << ", SectionB ID: " << SectionBID | 
|  | 261 | << ", SectionBOffset: " << SectionBOffset << "\n"); | 
|  | 262 | RelocationEntry R(SectionID, Offset, RelocType, Addend, SectionAID, | 
|  | 263 | SectionAOffset, SectionBID, SectionBOffset, IsPCRel, | 
|  | 264 | HalfDiffKindBits); | 
|  | 265 |  | 
|  | 266 | addRelocationForSection(R, SectionAID); | 
|  | 267 | addRelocationForSection(R, SectionBID); | 
|  | 268 |  | 
|  | 269 | return ++RelI; | 
|  | 270 | } | 
|  | 271 |  | 
| Lang Hames | a521688 | 2014-07-17 18:54:50 +0000 | [diff] [blame] | 272 | }; | 
|  | 273 | } | 
|  | 274 |  | 
|  | 275 | #undef DEBUG_TYPE | 
|  | 276 |  | 
| Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 277 | #endif |