RTEMS | Add RISCV libdl support (!312)
Pavel Pisa (@ppisa)
gitlab at rtems.org
Sun Nov 17 23:35:25 UTC 2024
Pavel Pisa commented on a discussion: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/312#note_115131
Hello Chris,
I have tested dl01 and it fails as well.
I have added some debug
```
diff --git a/cpukit/libdl/rtl-mdreloc-riscv.c b/cpukit/libdl/rtl-mdreloc-riscv.c
index 3409a12a2d..a813df96c8 100644
--- a/cpukit/libdl/rtl-mdreloc-riscv.c
+++ b/cpukit/libdl/rtl-mdreloc-riscv.c
@@ -168,6 +168,13 @@ rtems_rtl_elf_reloc_rela (rtems_rtl_obj* obj,
// Final PCREL value
Elf_Word pcrel_val = symvalue - ((Elf_Word)(uintptr_t) where);
+ printf ("rtl: rtems_rtl_elf_reloc_rela s.base %p s.offset 0x%lx info 0x%lx where %p *where %p in %s\n",
+ (void *)sect->base, (unsigned long)rela->r_offset,
+ (unsigned long)rela->r_info, where, (void*)0,
+ rtems_rtl_obj_oname (obj));
+ fflush(stdout);
+ sleep(1);
+
if (syminfo == STT_SECTION) {
return rtems_rtl_elf_rel_no_error;
}
```
The `*where` is disabled for now, because I have fear, that it causes problems.
It is suspicious that `sect->base` is zero. It should be zero for debugging sections etc. but I expect that such relocs should be skipped. May it be that they are. I can try to dig deeper tomorrow. I would expect that actual area allocated for the ELF image starts at 0x100004bde0 and that these relocs are form `.text` section.
```
*** BEGIN OF TEST libdl (RTL) 1 ***
*** TEST VERSION: 6.0.0.e049757c58-modified
*** TEST STATE: EXPECTED_PASS
*** TEST BUILD: RTEMS_POSIX_API RTEMS_SMP
*** TEST TOOLS: 13.3.0 20240521 (RTEMS 6, RSB e52d2288c8a0df64466010839ca1eb40c6d243ed, Newlib 1b3dcfd)
load: /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0xc info 0x3600000017 where 0xc *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0xc info 0x33 where 0xc *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x10 info 0x3700000018 where 0x10 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x10 info 0x33 where 0x10 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x14 info 0x3800000017 where 0x14 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x14 info 0x33 where 0x14 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x18 info 0x3900000018 where 0x18 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x18 info 0x33 where 0x18 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x1c info 0x7100000017 where 0x1c *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x1c info 0x33 where 0x1c *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x20 info 0x3a00000018 where 0x20 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x20 info 0x33 where 0x20 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x26 info 0x7200000013 where 0x26 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x26 info 0x33 where 0x26 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x2e info 0x3e00000010 where 0x2e *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x3a info 0x3b00000017 where 0x3a *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x3a info 0x33 where 0x3a *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x3e info 0x3c00000018 where 0x3e *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x3e info 0x33 where 0x3e *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x42 info 0x7100000017 where 0x42 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x42 info 0x33 where 0x42 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x46 info 0x3d00000018 where 0x46 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x46 info 0x33 where 0x46 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x54 info 0x7200000013 where 0x54 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x54 info 0x33 where 0x54 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x5e info 0x3f00000010 where 0x5e *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0x100004bde0 s.offset 0xc info 0x3600000017 where 0x100004bdec *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0x100004bde0 s.offset 0x10 info 0x3700000018 where 0x100004bdf0 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0x100004bde0 s.offset 0x14 info 0x3800000017 where 0x100004bdf4 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0x100004bde0 s.offset 0x18 info 0x3900000018 where 0x100004bdf8 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0x100004bde0 s.offset 0x1c info 0x7100000017 where 0x100004bdfc *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0x100004bde0 s.offset 0x20 info 0x3a00000018 where 0x100004be00 *where 0 in /dl01-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0x100004bde0 s.offset 0x26 info 0x7200000013 where 0x100004be06 *where 0 in /dl01-o1.o
*** FATAL ***
fatal source: 9 (RTEMS_FATAL_SOURCE_EXCEPTION)
CPU: 0
mstatus 0x8000000a00007880
mcause 0x0000000000000004
mepc 0x000000100000b538
ra 0x000000100000b4de
sp 0x000000100003d0c0
gp 0x0000001000032800
tp 0x000000100003d5d8
t0 0x0000000000000001
t1 0x0000000000000000
t2 0x0000000000000000
s0 0x000000100003d160
s1 0x0000000000002952
a0 0x0000000000000000
a1 0x000000100003ce60
a2 0x0000001000033d00
a3 0x0000007200000013
a4 0x000000100002d578
a5 0x000000100000b538
a6 0x0000000000000000
a7 0x00000010000324b0
s2 0x0000000000000010
s3 0x000000100004abd0
s4 0xfffffffffffb6b4c
s5 0x000000100004be06
s6 0x000000100004ae30
s7 0x0000000000000018
s8 0x0000000000000120
s9 0x000000000000000c
s10 0x0000000000000001
s11 0x000000100004b2b0
t3 0x0000000000000000
t4 0x0000000000000022
t5 0x02961afe000f4240
t6 0x000010c6f7a0b5ec
fcsr 0x00000000
RTEMS version: 6.0.0.e049757c58-modified
RTEMS tools: 13.3.0 20240521 (RTEMS 6, RSB e52d2288c8a0df64466010839ca1eb40c6d243ed, Newlib 1b3dcfd)
executing thread ID: 0x0a010001
executing thread name: UI1
```
The second test fails as well
```
*** BEGIN OF TEST libdl (RTL) 2 ***
*** TEST VERSION: 6.0.0.e049757c58-modified
*** TEST STATE: EXPECTED_PASS
*** TEST BUILD: RTEMS_POSIX_API RTEMS_SMP
*** TEST TOOLS: 13.3.0 20240521 (RTEMS 6, RSB e52d2288c8a0df64466010839ca1eb40c6d243ed, Newlib 1b3dcfd)
load: /dl02-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x8 info 0x11500000017 where 0x8 *where 0 in /dl02-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x8 info 0x33 where 0x8 *where 0 in /dl02-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0xc info 0x8300000018 where 0xc *where 0 in /dl02-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0xc info 0x33 where 0xc *where 0 in /dl02-o1.o
```
...
```
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x182 info 0x11600000013 where 0x182 *where 0 in /dl02-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x182 info 0x33 where 0x182 *where 0 in /dl02-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0 s.offset 0x18e info 0xae0000002d where 0x18e *where 0 in /dl02-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0x1000055ae0 s.offset 0x8 info 0x11500000017 where 0x1000055ae8 *where 0 in /dl02-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0x1000055ae0 s.offset 0xc info 0x8300000018 where 0x1000055aec *where 0 in /dl02-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0x1000055ae0 s.offset 0x10 info 0x8400000017 where 0x1000055af0 *where 0 in /dl02-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0x1000055ae0 s.offset 0x14 info 0x8500000018 where 0x1000055af4 *where 0 in /dl02-o1.o
rtl: rtems_rtl_elf_reloc_rela s.base 0x1000055ae0 s.offset 0x1a info 0x11600000013 where 0x1000055afa *where 0 in /dl02-o1.o
*** FATAL ***
fatal source: 9 (RTEMS_FATAL_SOURCE_EXCEPTION)
CPU: 0
mstatus 0x8000000a00007880
mcause 0x0000000000000004
mepc 0x000000100000b594
ra 0x000000100000b53a
sp 0x00000010000450b0
gp 0x000000100003a800
tp 0x00000010000455d8
t0 0x0000000000000001
t1 0x0000000000000000
t2 0x0000000000000000
s0 0x0000001000045150
s1 0x00000000000029ae
a0 0x0000000000000000
a1 0x0000001000044e50
a2 0x000000100003bd00
a3 0x0000011600000013
a4 0x0000001000034dc8
a5 0x000000100000b594
a6 0x0000000000000000
a7 0x000000100003a4b0
s2 0x0000000000000010
s3 0x0000001000052c60
s4 0xfffffffffffaceb4
s5 0x0000001000055afa
s6 0x0000001000052ec0
s7 0x0000000000000018
s8 0x00000000000000c0
s9 0x0000000000000008
s10 0x0000000000000001
s11 0x0000001000053570
t3 0x0000000000000000
t4 0x0000000000000084
t5 0x086f1447000f4240
t6 0x000010c6f7a0b5ec
fcsr 0x00000000
RTEMS version: 6.0.0.e049757c58-modified
RTEMS tools: 13.3.0 20240521 (RTEMS 6, RSB e52d2288c8a0df64466010839ca1eb40c6d243ed, Newlib 1b3dcfd)
executing thread ID: 0x0a010001
executing thread name: UI1
```
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/312#note_115131
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20241117/589c8eac/attachment-0001.htm>
More information about the bugs
mailing list