Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

understanding -PIE #369

Open
tswaehn opened this issue Aug 16, 2024 · 6 comments
Open

understanding -PIE #369

tswaehn opened this issue Aug 16, 2024 · 6 comments

Comments

@tswaehn
Copy link

tswaehn commented Aug 16, 2024

just want to understand why -PIE is hard coded.

if a bare metal build should be created, then this option prevents it.

thus shouldnt the -PIE option be optional?

hints:

currently I always have to apply this patch: 2fe7528

@SiFiveHolland
Copy link
Contributor

The OpenSBI firmware binary is no less bare metal because it is a PIE. OpenSBI applies relocations to itself as part of its entry assembly code, so there is no external dependency to load the firmware.

What problems do you experience when you don't patch OpenSBI?

@tswaehn
Copy link
Author

tswaehn commented Aug 17, 2024

What problems do you experience when you don't patch OpenSBI?

Actually my toolchain does not support PIE. I should figure out how to rebuild with PIE if needed. That would be ok.

I appreciate the self relocation and I am a fan of flexibility. Just wondering if optional use of PIE (depending of toolchain capabilities) would be an option.

For me there is two options fork and patch or find I way to achieve both in the main repo, without need to fork - which is my preferred option. Thats why I am trying to understand if PIE could be optional.

(actually this is what I am doing)

@tswaehn
Copy link
Author

tswaehn commented Aug 30, 2024

@SiFiveHolland Just wondering, if we could make the PIE option optional. So we could avoid forking the repo, as mentioned here.

@mikey
Copy link

mikey commented Aug 30, 2024

I think you just want to submit a patch to opensbi to make PIE an option, or even detect what the toolchain supports. The compile will need to specify FW_TEXT_START (or you could have a default of 0x80000000, like opensbi used to have)

@SiFiveHolland
Copy link
Contributor

Were you unable to update your toolchain to support PIE? OpenSBI is not the only firmware to be compiled as a PIE. For example, U-Boot is as well. This seems to be a deficiency in your toolchain.

@tswaehn
Copy link
Author

tswaehn commented Aug 31, 2024

I am using the standard toolchain of Zephyr OS. Same actually goes for all my other toolchains. Usually I don't need PIE.

And actually the question is why should I enable PIE un the tool chain, although I don't need it. Additionally why is there the requirement to build openSBI with PIE although it seems to me there is no actual technical reason that really forces it. Instead it looks to me like it's optional - so why not making it optional then?

If ok, I will prepare a PR for qemu builds without PIE option, where for other targets PIE will be enabled.

Would that be acceptable?

Side note, it would be a huge benefit, if openSBI could be built out-of-the-box for Zephyr. Because actually we want to use openSBI as per-se default for machine mode software and introduce supervisor mode based on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants