The implementation of dl_iterate_phdr for statically-linked binaries
abuses tls_get_addr to get to the start of the TLS block. For most
architectures, tls_index's ti_offset (relocated by DTPOFF/DTPREL for GOT
entries) is just the offset within that module's TLS block. However, for
PowerPC and RISC-V, which have a non-zero TLS_DTV_OFFSET and thus are
designed assuming DTV entries are biased by that value, ti_offset
normally has TLS_DTV_OFFSET pre-subtracted. By using an offset of zero
here we end up getting a pointer TLS_DTV_OFFSET past what tls_get_addr
would return for the first TLS variable.
Fix this by using -TLS_DTV_OFFSET to mirror what the General Dynamic GOT
entry for the first TLS variable would be.
(Note this also applies to MIPS on stable/13)
Fixes: dbd2053026a6 ("libc dl_iterate_phdr(): dlpi_tls_data is wrong")
MFC after: 1 week