main: Correct the pointer value of strtab on riscv/mips architectures

Merged Daniel van Vugt requested to merge vanvugt/gnome-shell:fix-issue-6528 into main

Glibc defines d_ptr/d_val to be a relocated address on most architectures, except for riscv and mips where it is just an offset from the binary load address. So we need to convert strtab from an offset into a pointer for riscv and mips.

Internally within glibc there is the D_PTR macro for doing this, which relies on private data hidden in an ABI-unstable part of link_map. So we can't use the same conditional logic as glibc does internally.

Our solution is to detect when strtab is unreasonably low (below the address of our binary) and so it must be an unrelocated offset. In that case we just do the relocation manually.

Fixes: #6528 (closed)

Merge request reports