Issue created by Anthony Cole: 
https://gitlab.rtems.org/rtems/tools/rtems-tools/-/work_items/49



**Summary**

`rtems-syms` puts the kernel's global and weak symbols in the symbol table 
(`symbols.globals ()` and `symbols.weaks ()` in `linkers/rtems-syms.cpp`). The 
compiler's support functions (`__adddf3`, `__muldf3`, `__extendsfdf2`, ...) are 
defined with hidden visibility, in libgcc and in compiler-rt alike. GNU ld 
keeps a hidden global symbol global in the kernel; LLVM's lld makes it local:

```
GNU ld (RSB 7, riscv/rv32imac):  GLOBAL HIDDEN __adddf3
LLVM lld (clang 19, RV32IMAFC):  LOCAL  HIDDEN __adddf3
```

So with lld the support functions the kernel contains never reach the symbol 
table, and a loaded object that needs one keeps it as an unresolved external.

**How it shows**

On a RISC-V target without double precision hardware, with clang and lld (the 
Codasip SDK): `dl02`'s loaded objects do double arithmetic and need `__muldf3`, 
`__adddf3`, `__eqdf2` and `__fixdfsi`. The kernel contains all of them 
(newlib's `printf` uses them), but they are local, so they stay unresolved, and 
the test hangs when it calls through one. The same applies to `dl07`-`dl09` 
(`__extendsfdf2`, once the kernel contains it, #5829 in rtems). With GCC and 
GNU ld the same tests pass.

This will matter for RTEMS's own LLVM toolchains, once the RSB builds them 
(rtems/tools/rtems-source-builder!308).

**Fix**

A local symbol with hidden visibility in a linked kernel was global in its 
object file; ordinary `static` symbols have default visibility. So add the 
defined functions and objects among the kernel's local symbols that have hidden 
visibility to the symbol table, alongside the global and weak ones (with a new 
`symbol::visibility ()` for `GELF_ST_VISIBILITY (st_other)`).

Tested: on a kernel linked by lld, the symbol table gains 39 symbols 
(compiler-rt's support functions and a few hidden libunwind internals), and all 
the libdl tests pass, `dl02` and `dl07`-`dl09` included, on RV32IMAFC (no D) 
and RV64 targets under QEMU; on kernels linked by GNU ld (`riscv/rv32imac`) the 
symbol table is unchanged. A merge request will follow.

**Environment**

rtems-tools `main` as of ddf047f (2026-11-19). Found with the Codasip SDK 
(clang 19, lld, compiler-rt) on RISC-V.

-- 
View it on GitLab: 
https://gitlab.rtems.org/rtems/tools/rtems-tools/-/work_items/49
You're receiving this email because of your account on gitlab.rtems.org. 
Unsubscribe from this thread: 
https://gitlab.rtems.org/-/namespace/13/sent_notifications/6-3huuozv9mt6qxjiq2fr1l42f9-d/unsubscribe
 | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | 
Help: https://gitlab.rtems.org/help


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to