From: Tom de Vries Date: Fri, 7 Mar 2025 08:25:33 +0000 (+0100) Subject: [gdb/tdep] Factor out rip_relative_p X-Git-Tag: binutils-2_45~1279 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a7769415cb4a3207de4c18baf46794344ab220d1;p=thirdparty%2Fbinutils-gdb.git [gdb/tdep] Factor out rip_relative_p Factor out rip_relative_p, and rewrite it to use MODRM_MOD_FIELD and MODRM_RM_FIELD. No functional changes. Tested on x86_64-linux. --- diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 8471ca61d89..a2da1392cdd 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -1207,6 +1207,18 @@ amd64_skip_prefixes (gdb_byte *insn) return insn; } +/* Return true if the MODRM byte of an insn indicates that the insn is + rip-relative. */ + +static bool +rip_relative_p (gdb_byte modrm) +{ + gdb_byte mod = MODRM_MOD_FIELD (modrm); + gdb_byte rm = MODRM_RM_FIELD (modrm); + + return mod == 0 && rm == 0x05; +} + /* Return a register mask for the integer registers that are used as an input operand in INSN. If !ASSUMPTIONS, only return the registers we actually found, for the benefit of self tests. */ @@ -1455,7 +1467,7 @@ fixup_displaced_copy (struct gdbarch *gdbarch, { gdb_byte modrm = details->raw_insn[details->modrm_offset]; - if ((modrm & 0xc7) == 0x05) + if (rip_relative_p (modrm)) { /* The insn uses rip-relative addressing. Deal with it. */ @@ -1789,7 +1801,7 @@ rip_relative_offset (struct amd64_insn *insn) { gdb_byte modrm = insn->raw_insn[insn->modrm_offset]; - if ((modrm & 0xc7) == 0x05) + if (rip_relative_p (modrm)) { /* The displacement is found right after the ModRM byte. */ return insn->modrm_offset + 1;