Skip to content

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

Jonas Ådahl requested to merge cherry-pick-65cde187 into gnome-44

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) Part-of: !2718 (merged)

(cherry picked from commit 65cde187)

Merge request reports