Skip to content

Add support for R_ARM_REL32 relocations.#3631

Merged
skotopes merged 2 commits intoflipperdevices:devfrom
Sameesunkaria:arm-rel32-relocation
May 13, 2024
Merged

Add support for R_ARM_REL32 relocations.#3631
skotopes merged 2 commits intoflipperdevices:devfrom
Sameesunkaria:arm-rel32-relocation

Conversation

@Sameesunkaria
Copy link
Copy Markdown
Contributor

@Sameesunkaria Sameesunkaria commented May 2, 2024

What's new

Add support for R_ARM_REL32 relocations.

It is fairly straightforward to correctly resolve an R_ARM_REL32 relocation as described in in the "Relocation types" section of ARM ELF Specification. It modifies the 32-bit word at the address being relocated, just like R_ARM_ABS32, but the value is resolved using 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.

Verification

I have manually tested that this relocation works correctly by building and running multiple apps that depend on this relocation being performed correctly.

Checklist (For Reviewer)

  • PR has description of feature/bug or link to Confluence/Jira task
  • Description contains actions to verify feature/bugfix
  • I've built this code, uploaded it to the device and verified feature/bugfix

@hedger hedger added New Feature Contains an IMPLEMENTATION of a new feature App Loader FAP loader + API-related labels May 8, 2024
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.
@Sameesunkaria Sameesunkaria force-pushed the arm-rel32-relocation branch from 31d1fdc to dd9488f Compare May 11, 2024 17:53
@Sameesunkaria
Copy link
Copy Markdown
Contributor Author

@hedger please let me know if you need a pre-compiled fap that requires R_ARM_REL32 relocations to help validate this change.

@skotopes
Copy link
Copy Markdown
Contributor

@Sameesunkaria yes, we do need it

@Sameesunkaria
Copy link
Copy Markdown
Contributor Author

Sameesunkaria commented May 11, 2024

Here's the .fap: Hello.fap.zip

It's compiled from the sources found on my repository: https://github.com/Sameesunkaria/swift-flipperzero-hello. The app fails to load with the error code "MissingImports" when you try launching it without the changes in this PR. You should see "Undefined relocation 3" in the logs.

Hope this helps :)

@skotopes
Copy link
Copy Markdown
Contributor

Seeing swift on flipper is really cool. Great work!

@skotopes skotopes merged commit 8ffee67 into flipperdevices:dev May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App Loader FAP loader + API-related New Feature Contains an IMPLEMENTATION of a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants