Skip to content

SystemInformation: Change GetRealAddress to return a size_t

Jessica Clarke requested to merge jrtc27/kwsys:SystemInformation-CHERI into master

The return value is not a real pointer, but an integer representing the offset of the symbol within the loaded binary/library (possibly including a load base). On CHERI, and thus Arm's Morello prototype, pointers are not just integers but are unforgeable hardware capabilities that contain additional metadata (including bounds and permissions) to provide fine-grained spatial safety. Casting a plain integer (in this case, a ptrdiff_t) to a void * gives a warning that we normally make fatal, as due to the unforgeability of capabilities it will not be a valid pointer, trapping on dereference. Whilst there are ways to squash this warning (typically by casting via (u)intptr_t), they are not appropriate here, since the return value does not need to be a void *, and are normally only needed for reusing void *-taking interfaces with a plain integer (e.g. pthread_create's void * argument). Thus change the return type to be size_t to represent that this is the non-negative integer offset of the address from the base address.

Note that, other than the dummy call in the constructor that throws away the result, this member function is unused.

Merge request reports