1- // ===-- RuntimeDyldCOFFAArch64.h --- COFF/AArch64 specific code ---*- C++
2- // -*-===//
1+ // ===-- RuntimeDyldCOFFAArch64.h --- COFF/AArch64 specific code ---*- C++*-===//
32//
43// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
54// See https://llvm.org/LICENSE.txt for license information.
2221
2322#define DEBUG_TYPE " dyld"
2423
25- using namespace llvm ::support::endian;
26-
2724namespace llvm {
2825
2926// This relocation type is used for handling long branch instruction
@@ -32,16 +29,28 @@ enum InternalRelocationType : unsigned {
3229 INTERNAL_REL_ARM64_LONG_BRANCH26 = 0x111 ,
3330};
3431
35- static void add16 (uint8_t *p, int16_t v) { write16le (p, read16le (p) + v); }
36- static void or32le (void *P, int32_t V) { write32le (P, read32le (P) | V); }
32+ static void add16 (uint8_t *p, int16_t v) {
33+ using namespace llvm ::support::endian;
34+ write16le (p, read16le (p) + v);
35+ }
36+
37+ static void or32le (void *P, int32_t V) {
38+ using namespace llvm ::support::endian;
39+
40+ write32le (P, read32le (P) | V);
41+ }
3742
3843static void write32AArch64Imm (uint8_t *T, uint64_t imm, uint32_t rangeLimit) {
44+ using namespace llvm ::support::endian;
45+
3946 uint32_t orig = read32le (T);
4047 orig &= ~(0xFFF << 10 );
4148 write32le (T, orig | ((imm & (0xFFF >> rangeLimit)) << 10 ));
4249}
4350
4451static void write32AArch64Ldr (uint8_t *T, uint64_t imm) {
52+ using namespace llvm ::support::endian;
53+
4554 uint32_t orig = read32le (T);
4655 uint32_t size = orig >> 30 ;
4756 // 0x04000000 indicates SIMD/FP registers
@@ -54,6 +63,8 @@ static void write32AArch64Ldr(uint8_t *T, uint64_t imm) {
5463}
5564
5665static void write32AArch64Addr (void *T, uint64_t s, uint64_t p, int shift) {
66+ using namespace llvm ::support::endian;
67+
5768 uint64_t Imm = (s >> shift) - (p >> shift);
5869 uint32_t ImmLo = (Imm & 0x3 ) << 29 ;
5970 uint32_t ImmHi = (Imm & 0x1FFFFC ) << 3 ;
@@ -144,6 +155,7 @@ class RuntimeDyldCOFFAArch64 : public RuntimeDyldCOFF {
144155 const object::ObjectFile &Obj,
145156 ObjSectionToIDMap &ObjSectionToID,
146157 StubMap &Stubs) override {
158+ using namespace llvm ::support::endian;
147159
148160 auto Symbol = RelI->getSymbol ();
149161 if (Symbol == Obj.symbol_end ())
@@ -255,6 +267,8 @@ class RuntimeDyldCOFFAArch64 : public RuntimeDyldCOFF {
255267 }
256268
257269 void resolveRelocation (const RelocationEntry &RE, uint64_t Value) override {
270+ using namespace llvm ::support::endian;
271+
258272 const auto Section = Sections[RE.SectionID ];
259273 uint8_t *Target = Section.getAddressWithOffset (RE.Offset );
260274 uint64_t FinalAddress = Section.getLoadAddressWithOffset (RE.Offset );
@@ -374,4 +388,6 @@ class RuntimeDyldCOFFAArch64 : public RuntimeDyldCOFF {
374388
375389} // End namespace llvm
376390
377- #endif
391+ #undef DEBUG_TYPE
392+
393+ #endif // LLVM_LIB_EXECUTIONENGINE_RUNTIMEDYLD_TARGETS_RUNTIMEDYLDCOFFAARCH64_H
0 commit comments