zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.94k stars 6.65k forks source link

Zephyr as PIC #80658

Open dev-72-Z opened 3 weeks ago

dev-72-Z commented 3 weeks ago

Is your feature request related to a problem? Please describe. I need to build Zephyr as position independent code.

Describe the solution you'd like To have PIC option in linker scripts, or to be able to set it with not to much intervention in the code.

Describe alternatives you've considered Tried to have .rodata section not dependent on absolute addresses set in .dts files. Didn't manage to move the initlevel section.

Additional context

github-actions[bot] commented 3 weeks ago

Hi @dev-72-Z! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

henrikbrixandersen commented 3 weeks ago

I need to build Zephyr as position independent code.

Please describe the use case a bit more.

dev-72-Z commented 3 weeks ago

We have memory addresses "hardcoded" in .dts files. Based on .dts file ~/include/generated/devicetree_generated.h is generated early in build process. The result binary, has .rodata section whose content depends on the absolute addresses from .dts file. Assuming we have several platforms for the same SOC, but with different .dts files. After any change in code we have to build binary for each one of them. If we had position independent code, i.e. no absolute addresses in .rodata, one binary could be used for all platforms.