Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable LoongArch target #4037

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add R_LARCH_64 relocation for loongarch
  • Loading branch information
xujuntwt95329 committed Mar 14, 2025
commit df04d38b0048461c503ab1c14cd9e80844c6b207
18 changes: 15 additions & 3 deletions core/iwasm/aot/arch/aot_reloc_loongarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "aot_reloc.h"

#define R_LARCH_64 2
#define R_LARCH_B26 66
#define R_LARCH_PCALA_HI20 71
#define R_LARCH_PCALA_LO12 72
Expand Down Expand Up @@ -93,9 +94,8 @@ typedef struct RelocTypeStrMap {
}

static RelocTypeStrMap reloc_type_str_maps[] = {
RELOC_TYPE_MAP(R_LARCH_B26),
RELOC_TYPE_MAP(R_LARCH_PCALA_HI20),
RELOC_TYPE_MAP(R_LARCH_PCALA_LO12),
RELOC_TYPE_MAP(R_LARCH_64), RELOC_TYPE_MAP(R_LARCH_B26),
RELOC_TYPE_MAP(R_LARCH_PCALA_HI20), RELOC_TYPE_MAP(R_LARCH_PCALA_LO12),
RELOC_TYPE_MAP(R_LARCH_CALL36),
};

Expand Down Expand Up @@ -202,6 +202,18 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
int64 X;

switch (reloc_type) {
case R_LARCH_64: /* S + A */
{
int64 val_64 = (int64)((intptr_t)S + (intptr_t)A);

CHECK_RELOC_OFFSET(sizeof(int64));
if (val_64 != ((intptr_t)S + (intptr_t)A)) {
goto fail_addr_out_of_range;
}

bh_memcpy_s(P, sizeof(int64_t), &val_64, sizeof(int64_t));
break;
}
case R_LARCH_B26:
case R_LARCH_CALL36: /* S + A - P */
{
Expand Down