[nasm:nasm-2.15.xx] assemble: use proper rel/abs state for lea reg,imm
nasm-bot for H. Peter Anvin (Intel)
hpa at zytor.com
Fri Jul 10 02:48:03 PDT 2020
Commit-ID: 254a56acca1511afadb30caa5e432b575f54ea43
Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=254a56acca1511afadb30caa5e432b575f54ea43
Author: H. Peter Anvin (Intel) <hpa at zytor.com>
AuthorDate: Fri, 10 Jul 2020 02:44:33 -0700
Committer: H. Peter Anvin (Intel) <hpa at zytor.com>
CommitDate: Fri, 10 Jul 2020 02:44:33 -0700
assemble: use proper rel/abs state for lea reg,imm
When using the LEA instruction with immediate syntax instead of memory
operand syntax, the IP_REL flag will not have made it into the operand
type. Make it do so.
Signed-off-by: H. Peter Anvin (Intel) <hpa at zytor.com>
---
asm/assemble.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/asm/assemble.c b/asm/assemble.c
index 2c47ba58..49faa6b8 100644
--- a/asm/assemble.c
+++ b/asm/assemble.c
@@ -2776,14 +2776,23 @@ static enum ea_type process_ea(operand *input, ea *output, int bits,
if (input->basereg == -1 &&
(input->indexreg == -1 || input->scale == 0)) {
/*
- * It's a pure offset.
+ * It's a pure offset. If it is an IMMEDIATE, it is a pattern
+ * in insns.dat which allows an immediate to be used as a memory
+ * address, in which case apply the default REL/ABS.
*/
- if (bits == 64 && ((input->type & IP_REL) == IP_REL)) {
- if (input->segment == NO_SEG ||
- (input->opflags & OPFLAG_RELATIVE)) {
- nasm_warn(WARN_OTHER|ERR_PASS2, "absolute address can not be RIP-relative");
- input->type &= ~IP_REL;
- input->type |= MEMORY;
+ if (bits == 64) {
+ if (is_class(IMMEDIATE, input->type)) {
+ if (!(input->eaflags & EAF_ABS) &&
+ ((input->eaflags & EAF_REL) || globalrel))
+ input->type |= IP_REL;
+ }
+ if ((input->type & IP_REL) == IP_REL) {
+ if (input->segment == NO_SEG ||
+ (input->opflags & OPFLAG_RELATIVE)) {
+ nasm_warn(WARN_OTHER|ERR_PASS2, "absolute address can not be RIP-relative");
+ input->type &= ~IP_REL;
+ input->type |= MEMORY;
+ }
}
}
More information about the Nasm-commits
mailing list