[Nasm-bugs] [Bug 3392797] Invalid addressing mode with "rel" simply disregards rel

noreply-nasm at dev.nasm.us noreply-nasm at dev.nasm.us
Mon Apr 18 14:19:32 PDT 2022


https://bugzilla.nasm.us/show_bug.cgi?id=3392797

--- Comment #4 from Liam Bowen <liambowen at gmail.com> ---
Patch submitted to list:

---
 asm/assemble.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/asm/assemble.c b/asm/assemble.c
index cd3f4693..dc5ee023 100644
--- a/asm/assemble.c
+++ b/asm/assemble.c
@@ -2264,6 +2264,17 @@ static void gencode(struct out_data *data, insn *ins)
                                rfield, rflags, ins, eat, &errmsg))
                     nasm_nonfatal("%s", errmsg);

+                /* If RIP-relative, indexreg and scale must not be present:
+                 * [basereg + indexreg*scale + displacement]
+                 * https://bugzilla.nasm.us/show_bug.cgi?id=3392797
+                 */
+                if (bits == 64 && (opy->eaflags & EAF_REL) &&
+                    ((opy->indexreg != -1) || (opy->scale != -1))) {
+                  nasm_warn(WARN_OTHER | ERR_PASS2,
+                            "invalid addressing mode: RIP-relative address "
+                            "cannot contain index register or scale");
+                }
+
                 p = bytes;
                 *p++ = ea_data.modrm;
                 if (ea_data.sib_present)
-- 
2.25.1

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are watching all bug changes.


More information about the Nasm-bugs mailing list