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

No support for -mno-pic-data-is-text-relative -msingle-pic-base options? #1587

Closed
yf13 opened this issue Oct 20, 2024 · 9 comments
Closed

No support for -mno-pic-data-is-text-relative -msingle-pic-base options? #1587

yf13 opened this issue Oct 20, 2024 · 9 comments

Comments

@yf13
Copy link

yf13 commented Oct 20, 2024

Hello there,

I am porting a Cortex-m4 project to rv32, the project uses position independent code for downloadable app modules. The project uses GNU arm toolchain with -fpic -fno-plt -mno-pic-data-is-text-relative -msingle-pic-base options for compilation.

I noticed that [issue#1521] and alike alredy explains that RiscV elf toolchain doesn't support PIC code generation and RiscV linux toolchain should be used instead.

Then I tried both riscv32-unknown-linux-gnu-gcc and riscv64-unknown-linux-musl-gcc but found that they both:

  • accept the -fpic -fno-plt options
  • reject the -mno-pic-data-is-text-relative -msingle-pic-base options.

I guess the first two are general GCC options and the last two are ARM specific options.
I am unsure if RiscV linux toolchain:

  • has same function for -fpic -fno-plt options like ARM toolchain?
  • has any equivalent options for -mno-pic-data-is-text-relative -msingle-pic-base ARM toolchain? if no such options, then what is RiscV toolchain's behavior regarding these two options?
@TommyMurphyTM1234
Copy link
Collaborator

I guess the first two are general GCC options

Correct:

and the last two are ARM specific options.

Correct:

I am unsure if RiscV linux toolchain: ...
has same function for -fpic -fno-plt options like ARM toolchain?

It does.

has any equivalent options for -mno-pic-data-is-text-relative -msingle-pic-base ARM toolchain?

It doesn't seem to:

what is RiscV toolchain's behavior regarding these two options?

It doesn't accept the Arm specific options. And it doesn't seem to have any equivalent capability. Not all GCC target architectures support the same compiler options.

Why not simply try compiling without those Arm specific options?

@yf13
Copy link
Author

yf13 commented Oct 20, 2024

Thank you @TommyMurphyTM1234 for the prompt reply.

So I will take that RiscV linux toolchain support -fpic -fno-plt but not -mno-pic-data-is-text-relative -msingle-pic-base, meaning the RiscV PIC feature has the assumption of data segments are relative to text segment.

@TommyMurphyTM1234
Copy link
Collaborator

So I will take that RiscV linux toolchain support -fpic -fno-plt but not -mno-pic-data-is-text-relative -msingle-pic-base,

Yes, that's what the GCC documentation says.

meaning the RiscV PIC feature has the assumption of data segments are relative to text segment.

I don't know. You might want to ask about this on the gcc-help mailing list.

@TommyMurphyTM1234 TommyMurphyTM1234 changed the title regarding PIC option differences No support for -mno-pic-data-is-text-relative -msingle-pic-base options? Oct 20, 2024
@aswaterman
Copy link
Collaborator

The existing RISC-V PIC scheme requires the GOT and local data be at a fixed offset from text.
IIRC, people have made proposals for an ABI that supports your use case, but they haven't yet been accepted, let alone implemented.

@TommyMurphyTM1234
Copy link
Collaborator

TommyMurphyTM1234 commented Oct 21, 2024

The existing RISC-V PIC scheme requires the GOT and local data be at a fixed offset from text. IIRC, people have made proposals for an ABI that supports your use case, but they haven't yet been accepted, let alone implemented.

Thanks for the clarification @aswaterman.
If/when you get a chance, would you happen to remember where such discussions took place and if they are captured anywhere that could be linked to, please?
Thanks again.

@TommyMurphyTM1234
Copy link
Collaborator

Closing this since it is something that needs to be dealt with in the relevant RISC-V ABI specification forum - here I think?

And then any concomitant changes implied by the ABI changes/enhancements implemented in the upstream toolchain projects.

@aswaterman
Copy link
Collaborator

Sorry for the delay in responding. Yes, the RISC-V ELF psABI spec is where these issues are discussed.

@TommyMurphyTM1234
Copy link
Collaborator

Sorry for the delay in responding. Yes, the RISC-V ELF psABI spec is where these issues are discussed.

Thanks a lot @aswaterman. 👍

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