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:
parent
3a677e3268
commit
92cbb63fc8
2 changed files with 35 additions and 7 deletions
|
@ -25,13 +25,14 @@
|
||||||
* Pre-processor Prototypes
|
* Pre-processor Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define R_X86_64_NONE 0
|
#define R_X86_64_NONE 0
|
||||||
#define R_X86_64_64 1
|
#define R_X86_64_64 1
|
||||||
#define R_X86_64_PC32 2
|
#define R_X86_64_PC32 2
|
||||||
#define R_X86_64_PLT32 4
|
#define R_X86_64_PLT32 4
|
||||||
#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;
|
||||||
|
|
Loading…
Reference in a new issue