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

llext: add initial support for arc #80078

Merged
merged 1 commit into from
Nov 16, 2024

Conversation

laurenmurphyx64
Copy link
Contributor

@laurenmurphyx64 laurenmurphyx64 commented Oct 18, 2024

Adds compiler flag(s) and architecture-specific relocations for ARC.

Notes:

  • Tests don't work without CONFIG_ARC_MPU_ENABLE=n
  • So userspace doesn't work (will come in with another PR)
  • Not all relocations supported (future PRs)

@teburd teburd self-assigned this Oct 22, 2024
@teburd teburd added area: ARC ARC Architecture area: llext Linkable Loadable Extensions labels Oct 22, 2024
subsys/llext/llext_link.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@pillo79 pillo79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, one more arch on the list! 👍

(all tests pass with just 2 relocations?)

Perhaps that's due to -mlong-calls. Not sure about the evils that may be unleashed dropping it though 🙂

subsys/llext/llext_link.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@mathieuchopstm mathieuchopstm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surface-level comments as I'm not well versed in ARC specifics:

arch/arc/core/elf.c Show resolved Hide resolved
include/zephyr/arch/arc/elf.h Outdated Show resolved Hide resolved
@laurenmurphyx64
Copy link
Contributor Author

laurenmurphyx64 commented Nov 1, 2024

Added R_ARC_B26 and R_ARC_S25W_PCREL to support hs5/6x, still need to fix some build errors on hs5x

Edit: Deferring build errors on two tests to another PR, to be linked with this issue

@abrodkin
Copy link
Collaborator

abrodkin commented Nov 7, 2024

Based on what relocations were generated by our testsuite, which turned out to be 4.

@laurenmurphyx64 what is that testsuite? May we look at it and see what kind of results it produces for ARC?

@laurenmurphyx64
Copy link
Contributor Author

laurenmurphyx64 commented Nov 7, 2024

Based on what relocations were generated by our testsuite, which turned out to be 4.

@laurenmurphyx64 what is that testsuite? May we look at it and see what kind of results it produces for ARC?

@abrodkin

We have 5 emulated ARC boards:

qemu_arc/qemu_arc_em      qemu_arc/qemu_arc_hs5x    qemu_arc/qemu_arc_hs/xip
qemu_arc/qemu_arc_hs      qemu_arc/qemu_arc_hs6x

To run the testsuite on one (keep adding -p [BOARD NAME] to run on multiple boards):

twister -T tests/subsys/llext/simple -p qemu_arc/qemu_arc_em

You can check the output in zephyrproject/zephyr/twister-out/. You can also run directly with West and see the build / run output in the console. I'd recommend doing this first because it's easier to see laid out.

west build -p -b qemu_arc/qemu_arc_em tests/subsys/llext/simple -t run

The tests output a lot of detail about relocations. Example:

D: Counting exported symbols...
D: symbol count 40
D: unhandled symbol 1, name threads_kernel_objects_ext.c, type tag 4, bind 0, sect 65521
D: unhandled symbol 2, name , type tag 3, bind 0, sect 1
D: unhandled symbol 3, name , type tag 3, bind 0, sect 3
D: unhandled symbol 4, name , type tag 3, bind 0, sect 4
D: unhandled symbol 5, name device_get_binding, type tag 2, bind 0, sect 1
D: unhandled symbol 6, name device_is_ready, type tag 2, bind 0, sect 1
D: unhandled symbol 7, name k_thread_create, type tag 2, bind 0, sect 1
D: unhandled symbol 8, name k_thread_join, type tag 2, bind 0, sect 1
...
D: Linking ELF...
D: relocation section .rela.text (2) acting on section 1 has 67 relocations
D: relocation 2:0 info 0x1711 (type 17, sym 23) offset 18 sym_name z_impl_device_get_binding sym_type 0 sym_bind 1 sym_ndx 0
I: found symbol z_impl_device_get_binding at 0x80009540
I: writing relocation symbol z_impl_device_get_binding type 17 sym 23 at addr 0x804032d2 addr 0x80009540
D: relocation 2:1 info 0x1811 (type 17, sym 24) offset 54 sym_name z_impl_device_is_ready sym_type 0 sym_bind 1 sym_ndx 0
I: found symbol z_impl_device_is_ready at 0x80009528
I: writing relocation symbol z_impl_device_is_ready type 17 sym 24 at addr 0x804032f6 addr 0x80009528
D: relocation 2:2 info 0x1911 (type 17, sym 25) offset 164 sym_name z_impl_k_thread_create sym_type 0 sym_bind 1 sym_ndx 0
I: found symbol z_impl_k_thread_create at 0x8000bac0
I: writing relocation symbol z_impl_k_thread_create type 17 sym 25 at addr 0x80403364 addr 0x8000bac0
D: relocation 2:3 info 0x1a11 (type 17, sym 26) offset 218 sym_name z_impl_k_thread_join sym_type 0 sym_bind 1 sym_ndx 0
I: found symbol z_impl_k_thread_join at 0x8000d22c
I: writing relocation symbol z_impl_k_thread_join type 17 sym 26 at addr 0x8040339a addr 0x8000d22c
...

The files in tests/subsys/llext/simple/src with the ending _ext.c are the sources for the test extensions, but if you run with Twister they / Zephyr are built with different CONFIG options specified in tests/subsys/llext/simple/testcase.yaml. tests/subsys/llext/simple/src/test_llext_simple.c is the actual Zephyr test app that loads, invokes, and unloads the compiled extensions.

teburd
teburd previously approved these changes Nov 7, 2024
teburd
teburd previously approved these changes Nov 14, 2024
ruuddw
ruuddw previously approved these changes Nov 14, 2024
lyakh
lyakh previously approved these changes Nov 14, 2024
Copy link
Collaborator

@pillo79 pillo79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Spotted 2 minor issues, not blockers but should probably be addressed in a followup PR.

tests/subsys/llext/simple/testcase.yaml Outdated Show resolved Hide resolved
tests/subsys/llext/simple/boards/qemu_arc_qemu_arc_em.conf Outdated Show resolved Hide resolved
@laurenmurphyx64 laurenmurphyx64 added the DNM This PR should not be merged (Do Not Merge) label Nov 14, 2024
Adds compiler flag(s) and some architecture-specific relocations
for ARC. No userspace support, doesn't support all relocations.

Signed-off-by: Lauren Murphy <[email protected]>
@laurenmurphyx64 laurenmurphyx64 removed the DNM This PR should not be merged (Do Not Merge) label Nov 14, 2024
@nashif nashif merged commit 99a5236 into zephyrproject-rtos:main Nov 16, 2024
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ARC ARC Architecture area: Build System area: llext Linkable Loadable Extensions area: Toolchains Toolchains
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants