Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 9 additions & 3 deletions core/iwasm/aot/aot_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -3160,7 +3160,9 @@ str2uint64(const char *buf, uint64 *p_res)
return true;
}

#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative offset to GOT */
#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative offset to GOT */
#define R_X86_64_GOTPCRELX 41 /* relaxable GOTPCREL */
#define R_X86_64_REX_GOTPCRELX 42 /* relaxable GOTPCREL with REX prefix */

static bool
is_text_section(const char *section_name)
Expand Down Expand Up @@ -3223,7 +3225,9 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group,
}
#if (defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64)) \
&& !defined(BH_PLATFORM_WINDOWS)
if (relocation->relocation_type == R_X86_64_GOTPCREL) {
if (relocation->relocation_type == R_X86_64_GOTPCREL
|| relocation->relocation_type == R_X86_64_GOTPCRELX
|| relocation->relocation_type == R_X86_64_REX_GOTPCRELX) {
GOTItem *got_item = module->got_item_list;
uint32 got_item_idx = 0;

Expand Down Expand Up @@ -3730,7 +3734,9 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
bh_memcpy_s(symbol_name_buf, (uint32)sizeof(symbol_name_buf),
symbol_name, symbol_name_len);

if (relocation.relocation_type == R_X86_64_GOTPCREL
if ((relocation.relocation_type == R_X86_64_GOTPCREL
|| relocation.relocation_type == R_X86_64_GOTPCRELX
|| relocation.relocation_type == R_X86_64_REX_GOTPCRELX)
&& !strncmp(symbol_name_buf, AOT_FUNC_PREFIX,
strlen(AOT_FUNC_PREFIX))) {
uint32 func_idx =
Expand Down
18 changes: 11 additions & 7 deletions core/iwasm/aot/arch/aot_reloc_x86_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
#include "aot_reloc.h"

#if !defined(BH_PLATFORM_WINDOWS)
#define R_X86_64_64 1 /* Direct 64 bit */
#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
#define R_X86_64_PLT32 4 /* 32 bit PLT address */
#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative offset to GOT */
#define R_X86_64_32 10 /* Direct 32 bit zero extended */
#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
#define R_X86_64_PC64 24 /* PC relative 64 bit */
#define R_X86_64_64 1 /* Direct 64 bit */
#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
#define R_X86_64_PLT32 4 /* 32 bit PLT address */
#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative offset to GOT */
#define R_X86_64_32 10 /* Direct 32 bit zero extended */
#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
#define R_X86_64_PC64 24 /* PC relative 64 bit */
#define R_X86_64_GOTPCRELX 41 /* relaxable GOTPCREL */
#define R_X86_64_REX_GOTPCRELX 42 /* relaxable GOTPCREL with REX prefix */
#else
#ifndef IMAGE_REL_AMD64_ADDR64
#define IMAGE_REL_AMD64_ADDR64 1 /* The 64-bit VA of the relocation target */
Expand Down Expand Up @@ -152,6 +154,8 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr,
#if !defined(BH_PLATFORM_WINDOWS)
case R_X86_64_PC32:
case R_X86_64_GOTPCREL: /* GOT + G has been calculated as symbol_addr */
case R_X86_64_GOTPCRELX:
case R_X86_64_REX_GOTPCRELX:
{
intptr_t target_addr = (intptr_t) /* S + A - P */
((uintptr_t)symbol_addr + reloc_addend
Expand Down
Loading