mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 12:40:15 +01:00
tools/mpy_ld.py: Add RV64 natmod support.
This commit adds the ability to compile native modules for the RV64 platform, using "rv64imc" as its architecture name (eg. "make ARCH=rv64imc" should build a RV64 natmod). The rest of 64-bits relocations needed to build a native module are now implemented, and all sample native modules build without errors or warnings. The same Picolibc caveats on RV32 also apply on RV64, thus the documentation was updated accordingly. RV64 native modules are also built as part of the CI process, but not yet executed as the QEMU port is not yet able to load and run them. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
@@ -49,6 +49,7 @@ MP_NATIVE_ARCH_ARMV7EMDP = 8
|
||||
MP_NATIVE_ARCH_XTENSA = 9
|
||||
MP_NATIVE_ARCH_XTENSAWIN = 10
|
||||
MP_NATIVE_ARCH_RV32IMC = 11
|
||||
MP_NATIVE_ARCH_RV64IMC = 12
|
||||
MP_PERSISTENT_OBJ_STR = 5
|
||||
MP_SCOPE_FLAG_VIPERRELOC = 0x10
|
||||
MP_SCOPE_FLAG_VIPERRODATA = 0x20
|
||||
@@ -62,6 +63,7 @@ R_RISCV_32 = 1
|
||||
R_X86_64_64 = 1
|
||||
R_XTENSA_32 = 1
|
||||
R_386_PC32 = 2
|
||||
R_RISCV_64 = 2
|
||||
R_X86_64_PC32 = 2
|
||||
R_ARM_ABS32 = 2
|
||||
R_386_GOT32 = 3
|
||||
@@ -175,7 +177,7 @@ def asm_jump_xtensa(entry):
|
||||
return struct.pack("<BH", jump_op & 0xFF, jump_op >> 8)
|
||||
|
||||
|
||||
def asm_jump_rv32(entry):
|
||||
def asm_jump_riscv(entry):
|
||||
# This could be 6 bytes shorter, but the code currently cannot
|
||||
# support a trampoline with varying length depending on the offset.
|
||||
|
||||
@@ -261,7 +263,14 @@ ARCH_DATA = {
|
||||
MP_NATIVE_ARCH_RV32IMC << 2,
|
||||
4,
|
||||
(R_RISCV_32, R_RISCV_GOT_HI20, R_RISCV_GOT32_PCREL),
|
||||
asm_jump_rv32,
|
||||
asm_jump_riscv,
|
||||
),
|
||||
"rv64imc": ArchData(
|
||||
"EM_RISCV",
|
||||
MP_NATIVE_ARCH_RV64IMC << 2,
|
||||
8,
|
||||
(R_RISCV_64, R_RISCV_GOT_HI20, R_RISCV_GOT32_PCREL),
|
||||
asm_jump_riscv,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -779,7 +788,7 @@ def do_relocation_data(env, text_addr, r):
|
||||
or env.arch.name == "EM_XTENSA"
|
||||
and r_info_type == R_XTENSA_32
|
||||
or env.arch.name == "EM_RISCV"
|
||||
and r_info_type == R_RISCV_32
|
||||
and r_info_type in (R_RISCV_32, R_RISCV_64)
|
||||
):
|
||||
# Relocation in data.rel.ro to internal/external symbol
|
||||
if env.arch.word_size == 4:
|
||||
|
||||
Reference in New Issue
Block a user