소스 검색

aot_reloc_arm.c: Implement R_ARM_MOVW_ABS_NC and R_ARM_MOVT_ABS (#1148)

Implement reloc type R_ARM_MOVW_ABS_NC and R_ARM_MOVT_ABS for arm,
refer to:
https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst#5614static-arm-relocations
YAMAMOTO Takashi 3 년 전
부모
커밋
3edb832f76
1개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  1. 17 0
      core/iwasm/aot/arch/aot_reloc_arm.c

+ 17 - 0
core/iwasm/aot/arch/aot_reloc_arm.c

@@ -8,6 +8,8 @@
 #define R_ARM_CALL 28  /* PC relative 24 bit (BL, BLX).  */
 #define R_ARM_JMP24 29 /* PC relative 24 bit (B/BL<cond>).  */
 #define R_ARM_ABS32 2  /* Direct 32 bit */
+#define R_ARM_MOVW_ABS_NC 43
+#define R_ARM_MOVT_ABS 44
 
 /* clang-format off */
 void __adddf3();
@@ -339,6 +341,21 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
                 + (intptr_t)reloc_addend;
             break;
         }
+        case R_ARM_MOVW_ABS_NC:
+        case R_ARM_MOVT_ABS:
+        {
+            uintptr_t *loc;
+            uintptr_t addr;
+            CHECK_RELOC_OFFSET(sizeof(void *));
+            loc = (uintptr_t *)(target_section_addr + (uint32)reloc_offset);
+            addr = (uintptr_t)symbol_addr + (intptr_t)reloc_addend;
+            if (reloc_type == R_ARM_MOVT_ABS) {
+                addr >>= 16;
+            }
+            *loc = ((*loc) & 0xfff0f000) | ((addr << 4) & 0x000f0000)
+                   | (addr & 0x00000fff);
+            break;
+        }
 
         default:
             if (error_buf != NULL)