https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79341
--- Comment #21 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Could libsanitizer call __tls_get_offset instead, after setting %r12 or whatever else is needed for it to make work and then perhaps adjust the result if needed? E.g. on s390x __tls_get_offset is internally: __tls_get_offset:\n\ la %r2,0(%r2,%r12)\n\ jg __tls_get_addr\n\ and in the interceptor: #ifdef __s390x__ "la %r2, 0(%r2,%r12)\n" "jg __interceptor___tls_get_addr_internal_protected\n" #else at which point the original %r2 and %r12 is lost and it is hard to call the original __tls_get_offset, it might be better to pass the original %r2 and %r12 values to some C function and from that compute the r2 + r12 the code perhaps needs for its own thing, but then we could (again in assembly) call the original __tls_get_offset again if needed. That said, if asan wants to intercept also what dlsym will internally call, then that will not really work. But does libasan on other targets rely on dlsym calling __tls_get_addr internally in those cases? That would be yet another reliance on glibc internals.