diff --git a/arch/arm/src/armv7-m/Kconfig b/arch/arm/src/armv7-m/Kconfig index b8c3cb8179..0e2e6b6866 100644 --- a/arch/arm/src/armv7-m/Kconfig +++ b/arch/arm/src/armv7-m/Kconfig @@ -106,6 +106,13 @@ config ARMV7M_OABI_TOOLCHAIN Most of the older buildroot toolchains are OABI and are named arm-nuttx-elf- vs. arm-nuttx-eabi- +config ARMV7M_TARGET2_PREL + bool "R_ARM_TARGET2 is PC relative" + default n + depends on ELF + ---help--- + Perform a PC relative relocation for relocation type R_ARM_TARGET2 + config ARMV7M_HAVE_STACKCHECK bool default n diff --git a/arch/arm/src/armv7-m/up_elf.c b/arch/arm/src/armv7-m/up_elf.c index c1ea4e4941..4c5155f665 100644 --- a/arch/arm/src/armv7-m/up_elf.c +++ b/arch/arm/src/armv7-m/up_elf.c @@ -48,6 +48,8 @@ #include #include +#ifdef CONFIG_ELF + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -60,6 +62,14 @@ * Private Functions ****************************************************************************/ +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef CONFIG_UCLIBCXX_EXCEPTION +extern void init_unwind_exidx(Elf32_Addr start, Elf32_Addr end); +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -204,6 +214,18 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym, } break; +#ifdef CONFIG_ARMV7M_TARGET2_PREL + case R_ARM_TARGET2: /* TARGET2 is a platform-specific relocation: gcc-arm-none-eabi + * performs a self relocation */ + { + bvdbg("Performing TARGET2 link at addr=%08lx [%08lx] to sym=%p st_value=%08lx\n", + (long)addr, (long)(*(uint32_t*)addr), sym, (long)sym->st_value); + + *(uint32_t*)addr += sym->st_value - addr; + } + break; +#endif + case R_ARM_THM_CALL: case R_ARM_THM_JUMP24: { @@ -464,3 +486,14 @@ int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym, bdbg("RELA relocation not supported\n"); return -ENOSYS; } + +#ifdef CONFIG_UCLIBCXX_EXCEPTION +int up_init_exidx(Elf32_Addr address, Elf32_Word size) +{ + init_unwind_exidx(address, size); + + return OK; +} +#endif + +#endif /* CONFIG_ELF */