forked from Imagelibrary/binutils-gdb
x86: support fs_base and gs_base for 32-bit inferiors on 64-bit kernels
On Linux 64-bit kernels provide fs_base and gs_base also for 32-bit inferiors. Add support for those registers. Also check for HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE consistently. Signed-off-by: Markus Metzger <markus.t.metzger@intel.com> gdb/ * amd64-linux-nat.c (amd64_linux_gregset32_reg_offset): Add FS_BASE and GS_BASE offsets. * amd64-linux-tdep.c (amd64_linux_gregset_reg_offset): Check HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE. (amd64_linux_read_description): Enable segments if HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE. * i386-linux-tdep.c (i386_linux_gregset_reg_offset): Add -1 for FS_BASE and GS_BASE offsets. (i386_linux_read_description): Enable segments if HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE. * i386-linux-tdep.h (I386_LINUX_ORIG_EAX_REGNUM): Update. Change-Id: I030b500a7a5b087452a78c3e0545d6e6e65146aa
This commit is contained in:
@@ -85,6 +85,11 @@ static int amd64_linux_gregset32_reg_offset[] =
|
|||||||
-1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */
|
-1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm7 (AVX512) */
|
-1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm7 (AVX512) */
|
||||||
-1, /* PKEYS register PKRU */
|
-1, /* PKEYS register PKRU */
|
||||||
|
#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE
|
||||||
|
FS_BASE * 8, GS_BASE * 8, /* fs_base and gs_base */
|
||||||
|
#else
|
||||||
|
-1, -1, /* fs_base and gs_base */
|
||||||
|
#endif
|
||||||
ORIG_RAX * 8 /* "orig_eax" */
|
ORIG_RAX * 8 /* "orig_eax" */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,11 @@ int amd64_linux_gregset_reg_offset[] =
|
|||||||
-1, /* PKEYS register pkru */
|
-1, /* PKEYS register pkru */
|
||||||
|
|
||||||
/* End of hardware registers */
|
/* End of hardware registers */
|
||||||
|
#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE
|
||||||
21 * 8, 22 * 8, /* fs_base and gs_base. */
|
21 * 8, 22 * 8, /* fs_base and gs_base. */
|
||||||
|
#else
|
||||||
|
-1, -1, /* fs_base and gs_base. */
|
||||||
|
#endif
|
||||||
15 * 8 /* "orig_rax" */
|
15 * 8 /* "orig_rax" */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1593,9 +1597,15 @@ amd64_linux_read_description (uint64_t xcr0_features_bit, bool is_x32)
|
|||||||
[(xcr0_features_bit & X86_XSTATE_PKRU) ? 1 : 0];
|
[(xcr0_features_bit & X86_XSTATE_PKRU) ? 1 : 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE
|
||||||
|
const bool segment = true;
|
||||||
|
#else
|
||||||
|
const bool segment = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (*tdesc == NULL)
|
if (*tdesc == NULL)
|
||||||
*tdesc = amd64_create_target_description (xcr0_features_bit, is_x32,
|
*tdesc = amd64_create_target_description (xcr0_features_bit, is_x32,
|
||||||
true, true);
|
true, segment);
|
||||||
|
|
||||||
return *tdesc;
|
return *tdesc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -609,6 +609,7 @@ int i386_linux_gregset_reg_offset[] =
|
|||||||
-1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */
|
-1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm7 (AVX512) */
|
-1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm7 (AVX512) */
|
||||||
-1, /* PKRU register */
|
-1, /* PKRU register */
|
||||||
|
-1, -1, /* fs_base and gs_base. */
|
||||||
11 * 4, /* "orig_eax" */
|
11 * 4, /* "orig_eax" */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -692,8 +693,14 @@ i386_linux_read_description (uint64_t xcr0)
|
|||||||
[(xcr0 & X86_XSTATE_AVX512) ? 1 : 0]
|
[(xcr0 & X86_XSTATE_AVX512) ? 1 : 0]
|
||||||
[(xcr0 & X86_XSTATE_PKRU) ? 1 : 0];
|
[(xcr0 & X86_XSTATE_PKRU) ? 1 : 0];
|
||||||
|
|
||||||
|
#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE
|
||||||
|
const bool segment = true;
|
||||||
|
#else
|
||||||
|
const bool segment = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (*tdesc == NULL)
|
if (*tdesc == NULL)
|
||||||
*tdesc = i386_create_target_description (xcr0, true, false);
|
*tdesc = i386_create_target_description (xcr0, true, segment);
|
||||||
|
|
||||||
return *tdesc;
|
return *tdesc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
/* Register number for the "orig_eax" pseudo-register. If this
|
/* Register number for the "orig_eax" pseudo-register. If this
|
||||||
pseudo-register contains a value >= 0 it is interpreted as the
|
pseudo-register contains a value >= 0 it is interpreted as the
|
||||||
system call number that the kernel is supposed to restart. */
|
system call number that the kernel is supposed to restart. */
|
||||||
#define I386_LINUX_ORIG_EAX_REGNUM (I386_PKRU_REGNUM + 1)
|
#define I386_LINUX_ORIG_EAX_REGNUM (I386_GSBASE_REGNUM + 1)
|
||||||
|
|
||||||
/* Total number of registers for GNU/Linux. */
|
/* Total number of registers for GNU/Linux. */
|
||||||
#define I386_LINUX_NUM_REGS (I386_LINUX_ORIG_EAX_REGNUM + 1)
|
#define I386_LINUX_NUM_REGS (I386_LINUX_ORIG_EAX_REGNUM + 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user