Runtime Loader Exported Symbols Address Size

Alex White alex.white at oarcorp.com
Fri Jun 17 19:27:58 UTC 2022


Hi,

While testing libdl on AArch64 QEMU, we found a bug where the exported symbol table appears to always use 32-bit values for addresses, but where the exported symbols table is read in `rtems_rtl_symbol_global_add`, the addresses are expected to be of size `sizeof(unsigned long)`.

This did not cause a problem on ARM since `sizeof(unsigned long)` is 4, but with AArch64 `sizeof(unsigned long)` is 8. So it is trying to read the address as 64 bits instead of 32.

The simple fix is to use an exact-width integer type - like `sizeof(uint32_t)`. But this would not allow for 64-bit architectures to use the full address space. It would also break on 64-bit RISC-V (see below). Perhaps we could have an ifdef to choose a 32 or 64-bit type based on the architecture rather than relying on `sizeof(unsigned long)`?

It looks like there is an exception in the rtems-syms tool for 64-bit RISC-V to emit 64-bit addresses rather than 32-bit addresses. Is this the right solution? Should we add another exception for AArch64?

Thanks,

Alex


More information about the devel mailing list