Issue created by Anthony Cole: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5829



**Summary**

The loaded objects of `dl07`, `dl08` and `dl09` print `float` variables with 
`printf( "%f", ... )`, for example `dl01_data2` in `dl07-o1.c`. A `float` 
passed to `printf()` is promoted to `double`. Without double precision floating 
point hardware the compiler does that with a support function, `__extendsfdf2` 
(libgcc). The base image doesn't use it, so it isn't linked in, `rtems-syms` 
doesn't put it in the symbol table, and the loaded objects keep it as an 
unresolved external. The tests then fail their check that all externals are 
resolved.

**How it shows**

On `riscv/rv32imac` and `riscv/rv64imac`, under QEMU `virt`, with the RSB 7 
toolchain (GCC 15.2.0):

```
dl07: ../../../testsuites/libtests/dl07/dl-load.c: 80 unresolved == 0
dl08: ../../../testsuites/libtests/dl08/dl-load.c: 80 unresolved == 0
dl09: handle: 0x...: unresolved externals
```

`__extendsfdf2` is the only symbol the loaded objects need that the image 
lacks. The other libdl tests pass. (The 80 in `80 unresolved == 0` is the line 
number of the check in `dl-load.c`, not a count of symbols.)

This is the dl07-dl09 failure that #5770 found on `mips/jmr3904` once it is 
built soft float, and left for a decision of its own; this issue is for that 
decision. The same is expected on the other RISC-V variants without the D 
extension (`rv32i`, `rv32iac`, `rv32im`, `rv32imafc`), and on other soft-float 
targets whose base image doesn't happen to contain `__extendsfdf2`. With double 
precision hardware the conversion is an instruction, and the tests pass 
(`rv64imafdc`).

**Fix**

The options we see:

1. Make the base program of each of the three tests convert a `float` to a 
`double` once, so that the support function is linked in and exported where the 
target needs it (below; tested).
2. Change the loaded objects so they don't promote `float` (for example print 
the value's bits as an integer). This changes what the tests check.
3. Link the base image with the whole compiler runtime, so that loaded objects 
find any support function. This is the general answer to "a loaded object can 
only use the support functions the base image happens to contain", but it makes 
every libdl test image larger.

Option 1 is the smallest change that makes the tests pass:

```c
/*


 * The loaded objects print float values, which are promoted to double.
 * Without double precision floating point hardware the compiler calls a
 * support function for that, which the objects can only use if the base
 * image has it: convert a float to a double here, so that it does.
 */
volatile float dl_load_float = 1.0f;
volatile double dl_load_double;

int dl_load_test( void )
{
  dl_load_double = dl_load_float;
  ...
```

in `testsuites/libtests/dl07/dl-load.c`, `dl08/dl-load.c` and `dl09/dl-load.c`. 
Tried on `dl07`: `__extendsfdf2` is then in its symbol table, and the test 
passes on `rv32imac` and `rv64imac`. On targets with hardware double precision 
the conversion is an instruction and nothing changes. If that approach is 
acceptable, a merge request will follow; it should also fix `mips/jmr3904` 
built soft float, if `__extendsfdf2` is the only helper missing there too.

**Environment**

RTEMS `main` as of 17bb6e147c (2026-11-19), `riscv/rv32imac` and 
`riscv/rv64imac`, RSB 7 toolchain, QEMU `virt`.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5829
You're receiving this email because of your account on gitlab.rtems.org. 
Unsubscribe from this thread: 
https://gitlab.rtems.org/-/namespace/49/sent_notifications/6-btc4ky93buh5jwcszd5dsvllv-1d/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