mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
Add support for R_ARM_REL32 relocations. (#3631)
It is fairly straightforward to correctly resolve an R_ARM_REL32 relocation as described in in the "Relocation types" section of ARM ELF Specification (https://developer.arm.com/documentation/espc0003/1-0/?lang=en). The documentation provides the following formula: ``` S - P + A ``` where `S` is the value of the symbol (symAddr), `P` is the address of the place being relocated (relAddr), and `A` is the addend (value extracted from the storage unit being relocated, in this case). I encountered the R_ARM_REL32 relocation type as part of my work for building apps written in Swift for the Flipper Zero. I have manually tested that this relocation works correctly by building and running multiple apps that depend on this relocation. Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -202,6 +202,7 @@ __attribute__((unused)) static const char* elf_reloc_type_to_str(int symt) {
|
|||||||
STRCASE(R_ARM_NONE)
|
STRCASE(R_ARM_NONE)
|
||||||
STRCASE(R_ARM_TARGET1)
|
STRCASE(R_ARM_TARGET1)
|
||||||
STRCASE(R_ARM_ABS32)
|
STRCASE(R_ARM_ABS32)
|
||||||
|
STRCASE(R_ARM_REL32)
|
||||||
STRCASE(R_ARM_THM_PC22)
|
STRCASE(R_ARM_THM_PC22)
|
||||||
STRCASE(R_ARM_THM_JUMP24)
|
STRCASE(R_ARM_THM_JUMP24)
|
||||||
default:
|
default:
|
||||||
@@ -329,6 +330,10 @@ static bool elf_relocate_symbol(ELFFile* elf, Elf32_Addr relAddr, int type, Elf3
|
|||||||
*((uint32_t*)relAddr) += symAddr;
|
*((uint32_t*)relAddr) += symAddr;
|
||||||
FURI_LOG_D(TAG, " R_ARM_ABS32 relocated is 0x%08X", (unsigned int)*((uint32_t*)relAddr));
|
FURI_LOG_D(TAG, " R_ARM_ABS32 relocated is 0x%08X", (unsigned int)*((uint32_t*)relAddr));
|
||||||
break;
|
break;
|
||||||
|
case R_ARM_REL32:
|
||||||
|
*((uint32_t*)relAddr) += symAddr - relAddr;
|
||||||
|
FURI_LOG_D(TAG, " R_ARM_REL32 relocated is 0x%08X", (unsigned int)*((uint32_t*)relAddr));
|
||||||
|
break;
|
||||||
case R_ARM_THM_PC22:
|
case R_ARM_THM_PC22:
|
||||||
case R_ARM_CALL:
|
case R_ARM_CALL:
|
||||||
case R_ARM_THM_JUMP24:
|
case R_ARM_THM_JUMP24:
|
||||||
|
|||||||
Reference in New Issue
Block a user