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

elf2flt: add riscv 64-bits support v3 #29

Merged

Conversation

gregungerer
Copy link
Contributor

Add support for riscv 64bits ISA by defining the relocation types R_RISCV_32_PCREL, R_RISCV_ADD32, R_RISCV_SUB32, R_RISCV_32 and R_RISCV_64. riscv64 support also needs the __global_pointer$ symbol to be defined right after the relocation tables in the data section. To define this symbol, the "RISCV_GP" line prefix is added. The "RISCV_GP" string is removed if the target CPU type is riscv64 and the definition line is dropped for other CPU types.

With these changes, buildroot and busybox build and run on riscv NOMMU systems with Linux kernel including patch 6045ab5fea4c ("binfmt_flat: do not stop relocating GOT entries prematurely on riscv") fixing the binfmt_flat loader. Tested on QEMU and Canaan Kendryte K210 boards.

This patch is based on earlier work by Christoph Hellwig [email protected].

Add support for riscv 64bits ISA by defining the relocation types
R_RISCV_32_PCREL, R_RISCV_ADD32, R_RISCV_SUB32, R_RISCV_32 and
R_RISCV_64. riscv64 support also needs the __global_pointer$ symbol to
be defined right after the relocation tables in the data section. To
define this symbol, the "RISCV_GP" line prefix is added. The "RISCV_GP"
string is removed if the target CPU type is riscv64 and the definition
line is dropped for other CPU types.

With these changes, buildroot and busybox build and run on riscv NOMMU
systems with Linux kernel including patch 6045ab5fea4c
("binfmt_flat: do not stop relocating GOT entries prematurely on riscv")
fixing the binfmt_flat loader. Tested on QEMU and Canaan Kendryte K210
boards.

This patch is based on earlier work by Christoph Hellwig <[email protected]>.

Signed-off-by: Damien Le Moal <[email protected]>
@gregungerer
Copy link
Contributor Author

This is an update of the most recent v2 patches. It is only the single RISC-V 64 bit commit. It has had the extra set of relocation types from Waldemar Brodkorb squashed into it, but it is otherwise pretty much Damien Le Moal's last patch for this, but all rebased on top of the current main branch.

As far as I can tell all previous comments and request for change have been made.

I have done some testing of it with the latest bintutils (2.41), gcc (13.2.0), linux kerneli (6.4), uClibc (1.0.43) and busybox (1.36.1), and it seems to work ok for those. I tried some old binutils, gcc and linux kernel and they seemed ok too.

@franzflasch
Copy link

Sorry, I did not see this PR before my other comment in #24 . I will test this.

@gregungerer gregungerer merged commit c5c8043 into uclinux-dev:main Sep 6, 2023
1 check passed
@gregungerer gregungerer deleted the gregungerer/riscv-nommu-v3 branch September 6, 2023 11:31
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

Successfully merging this pull request may close these issues.

3 participants