Make TLS detection only X86-specific (#4378)

This commit is contained in:
z3phyr 2024-03-22 09:37:39 -04:00 committed by GitHub
parent fb6efca4b5
commit ab593b3c7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View file

@ -886,9 +886,14 @@ static bool GH(parse_tcache_from_addr)(RzCore *core, GHT tls_addr, GHT tid) {
*/
static bool GH(parse_tls_data)(RzCore *core, RZ_NONNULL RzDebugPid *th, GHT tid) {
rz_return_val_if_fail(th, false);
GHT tls_addr = GHT_MAX;
ut8 dtv[sizeof(GHT)] = { 0 };
if (!th->tls) {
return false;
}
rz_io_nread_at(core->io, th->tls + (SZ), dtv, sizeof(GHT));
GHT addr = GH(read_val)(core, dtv, false);
memset(dtv, 0, sizeof(dtv));

View file

@ -890,6 +890,7 @@ RZ_API ut64 get_linux_tls_val(RZ_NONNULL RzDebug *dbg, int tid) {
rz_debug_reg_sync(dbg, RZ_REG_TYPE_GPR, false);
}
#if (__x86_64__ || __i386__)
RzRegItem *ri = rz_reg_get(dbg->reg, "fs", RZ_REG_TYPE_ANY);
RZ_DEBUG_REG_T regs;
// Fetch gs_base from a ptrace call
@ -900,6 +901,7 @@ RZ_API ut64 get_linux_tls_val(RZ_NONNULL RzDebug *dbg, int tid) {
} else {
tls = rz_reg_get_value(dbg->reg, ri);
}
#endif
// Must execute this block everytime
if (dbg->tid != tid) {
@ -961,6 +963,8 @@ RzList /*<RzDebugPid *>*/ *linux_thread_list(RzDebug *dbg, int pid, RzList /*<Rz
rz_debug_reg_sync(dbg, RZ_REG_TYPE_GPR, false);
pc = rz_debug_reg_get(dbg, "PC");
#if (__x86_64__ || __i386__)
RzRegItem *ri = rz_reg_get(dbg->reg, "fs", RZ_REG_TYPE_ANY);
RZ_DEBUG_REG_T regs;
// Fetch gs_base from a ptrace call
@ -971,6 +975,7 @@ RzList /*<RzDebugPid *>*/ *linux_thread_list(RzDebug *dbg, int pid, RzList /*<Rz
} else {
tls = rz_reg_get_value(dbg->reg, ri);
}
#endif
if (!procfs_pid_slurp(tid, "status", info, sizeof(info))) {
// Get information about pid (status, pc, etc.)