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.05k stars 6.18k forks source link

llext: fix issues in read-only code paths on Xtensa #75341

Open pillo79 opened 5 days ago

pillo79 commented 5 days ago

Describe the solution you'd like Currently LLEXT support on the Xtensa architecture depends on CONFIG_LLEXT_STORAGE_WRITABLE being enabled. Not doing so results in loading issues, as shown in this sample CI run.

To Reproduce This is reproducible with the patch in #75337.

Expected behavior Tests should pass successfully under these conditions.

Logs and console output Sample run of llext.simple.readonly on qemu_xtensa:

D: Loading ELF data...
D: Loading shared ELF
D: Finding ELF tables...
D: section 0 at 0x0: name 0, type 0, flags 0x0, addr 0x0, size 0, link 0, info 0
D: section 1 at 0x94: name 11, type 5, flags 0x2, addr 0x94, size 56, link 2, info 0
D: section 2 at 0xcc: name 17, type 11, flags 0x2, addr 0xcc, size 144, link 3, info 1
D: symtab at 2
D: section 3 at 0x15c: name 25, type 3, flags 0x2, addr 0x15c, size 84, link 0, info 0
D: strtab at 3
D: section 4 at 0x1b0: name 33, type 4, flags 0x2, addr 0x1b0, size 156, link 2, info 0
D: section 5 at 0x24c: name 43, type 4, flags 0x42, addr 0x24c, size 48, link 2, info 10
D: section 6 at 0x27c: name 53, type 1, flags 0x6, addr 0x27c, size 373, link 0, info 0
D: section 7 at 0x3f4: name 59, type 1, flags 0x2, addr 0x3f4, size 227, link 0, info 0
D: section 8 at 0x4d8: name 67, type 1, flags 0x2, addr 0x4d8, size 16, link 0, info 0
D: section 9 at 0x4e8: name 76, type 6, flags 0x3, addr 0x14e8, size 160, link 3, info 0
D: section 10 at 0x588: name 85, type 1, flags 0x3, addr 0x1588, size 4, link 0, info 0
D: section 11 at 0x58c: name 90, type 1, flags 0x3, addr 0x158c, size 8, link 0, info 0
D: section 12 at 0x594: name 104, type 8, flags 0x3, addr 0x1594, size 8, link 0, info 0
D: section 13 at 0x594: name 109, type 1, flags 0x30, addr 0x0, size 32, link 0, info 0
D: section 14 at 0x5b4: name 118, type 7, flags 0x0, addr 0x0, size 56, link 0, info 0
D: section 15 at 0x5ec: name 1, type 3, flags 0x0, addr 0x0, size 131, link 0, info 0
D: shstrtab at 15
D: Allocate and copy strings...
D: mem idx 7: start 0x19960, size 160
D: mem idx 6: start 0x19a20, size 96
D: Mapping ELF sections...
D: section 0 name  skipped
D: section 1 name .hash skipped
D: section 2 name .dynsym skipped
D: section 3 name .dynstr skipped
D: section 4 name .rela.dyn skipped
D: section 5 name .rela.plt skipped
D: section 6 name .text maps to idx 0
D: section 7 name .rodata maps to idx 2
D: section 8 name .got.loc maps to idx 2
D: section 9 name .dynamic skipped
D: section 10 name .got maps to idx 1
D: section 11 name .exported_sym maps to idx 4
D: section 12 name .bss maps to idx 3
D: section 13 name .comment skipped
D: section 14 name .xtensa.info skipped
D: section 15 name .shstrtab skipped
D: Allocate and copy sections...
D: mem idx 0: start 0x19aa0, size 384
D: mem idx 1: start 0x19c40, size 32
D: mem idx 2: start 0x19c80, size 256
D: mem idx 3: start 0x19da0, size 32
D: mem idx 4: start 0x19de0, size 32
D: mem idx 5: start 0x19e20, size 160
D: Counting exported symbols...
D: symbol count 9
D: function symbol 1, name test_entry, type tag 2, bind 1, sect 6
D: unhandled symbol 2, name ztest_test_fail, type tag 0, bind 1, sect 0
D: unhandled symbol 3, name vprintk, type tag 0, bind 1, sect 0
D: unhandled symbol 4, name printk, type tag 0, bind 1, sect 0
D: unhandled symbol 5, name __bss_start, type tag 0, bind 1, sect 11
D: unhandled symbol 6, name ztest_relative_filename, type tag 0, bind 1, sect 0
D: unhandled symbol 7, name _edata, type tag 0, bind 1, sect 11
D: unhandled symbol 8, name _end, type tag 0, bind 1, sect 12
D: Allocating memory for symbol table...
D: Copying symbols...
D: function symbol 0 name test_entry addr 0x19ba4
D: Linking ELF...
D: Found 0x19981 in PLT 4 size 12 cnt 13 text 0x19aa0
D: symbol  offset 0x1c r-offset 0x298 .text offset 0x27c stb 0
D: symbol  offset 0x28 r-offset 0x2a4 .text offset 0x27c stb 0
D: symbol  offset 0x30 r-offset 0x2ac .text offset 0x27c stb 0
D: symbol  offset 0x34 r-offset 0x2b0 .text offset 0x27c stb 0
D: symbol  offset 0x38 r-offset 0x2b4 .text offset 0x27c stb 0
D: symbol  offset 0x3c r-offset 0x2b8 .text offset 0x27c stb 0
D: symbol  offset 0x40 r-offset 0x2bc .text offset 0x27c stb 0
D: symbol  offset 0x44 r-offset 0x2c0 .text offset 0x27c stb 0
D: symbol  offset 0x48 r-offset 0x2c4 .text offset 0x27c stb 0
D: symbol  offset 0x310 r-offset 0x158c .text offset 0x27c stb 0
D: symbol  offset 0 r-offset 0x27c .text offset 0x27c stb 0
D: symbol  offset 0x4 r-offset 0x280 .text offset 0x27c stb 0
D: symbol test_entry offset 0x314 r-offset 0x1590 .text offset 0x27c stb 1
D: Found 0x1998b in PLT 4 size 12 cnt 4 text 0x19aa0
D: symbol ztest_relative_filename offset 0x18 r-offset 0x294 .text offset 0x27c stb 1
D: symbol printk offset 0x20 r-offset 0x29c .text offset 0x27c stb 1
D: symbol vprintk offset 0x24 r-offset 0x2a0 .text offset 0x27c stb 1
D: symbol ztest_test_fail offset 0x2c r-offset 0x2a8 .text offset 0x27c stb 1
D: sym 0 name  in 0x19a04
D: loaded module, .text at 0x19aa0, .rodata at 0x19c80
I: Loaded extension hello_world

    Assertion failed at WEST_TOPDIR/zephyr/tests/subsys/llext/simple/src/test_llext_simple.c:122: load_call_unload: (test_entry_fn is NULL)
test_entry should be an exported symbol
 FAIL - test_load_unload_hello_world in 0.018 seconds

Environment (please complete the following information): CI and current main (v3.7.0-rc2).

teburd commented 5 days ago

Thanks for filing this