mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
arch/x86_64: add basic support for R_X86_64_REX_GOTPCRELX relocation
GOTPCRELX reloc available only for CONFIG_ARCH_ADDRENV=y when CONFIG_ARCH_ADDRENV is not set, CONFIG_ARCH_TEXT_VBASE is not specified so we can't relocate Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
This commit is contained in:
committed by
Xiang Xiao
parent
3a677e3268
commit
92cbb63fc8
@@ -32,6 +32,7 @@
|
|||||||
#define R_X86_64_32 10
|
#define R_X86_64_32 10
|
||||||
#define R_X86_64_32S 11
|
#define R_X86_64_32S 11
|
||||||
#define R_X86_64_PC64 24
|
#define R_X86_64_PC64 24
|
||||||
|
#define R_X86_64_REX_GOTPCRELX 42
|
||||||
|
|
||||||
/* 4.3.1 ELF Identification. Should have:
|
/* 4.3.1 ELF Identification. Should have:
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -37,6 +37,13 @@
|
|||||||
|
|
||||||
#include <nuttx/elf.h>
|
#include <nuttx/elf.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define OPCODE_MOV 0x8b
|
||||||
|
#define OPCODE_LEA 0x8d
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -174,6 +181,26 @@ int up_relocateadd(const Elf64_Rela *rel, const Elf64_Sym *sym,
|
|||||||
|
|
||||||
*(uint32_t *)addr = value;
|
*(uint32_t *)addr = value;
|
||||||
break;
|
break;
|
||||||
|
#ifdef CONFIG_ARCH_ADDRENV
|
||||||
|
case R_X86_64_REX_GOTPCRELX:
|
||||||
|
|
||||||
|
/* Handle like R_X86_64_PC32 but with load offset */
|
||||||
|
|
||||||
|
value = (sym->st_value + rel->r_addend - addr +
|
||||||
|
CONFIG_ARCH_TEXT_VBASE);
|
||||||
|
|
||||||
|
/* Convert MOV to LEA - other relocations not suported */
|
||||||
|
|
||||||
|
if (*(uint8_t *)(addr - 2) != OPCODE_MOV)
|
||||||
|
{
|
||||||
|
berr("ERROR: not supported REX_GOTPCRELX relocation\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(uint8_t *)(addr - 2) = OPCODE_LEA;
|
||||||
|
*(uint32_t *)(addr) = value;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
berr("ERROR: Unsupported relocation: %d\n", relotype);
|
berr("ERROR: Unsupported relocation: %d\n", relotype);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|||||||
Reference in New Issue
Block a user