From 80cc2029d31f4a7f1cd4334b9cfaf9556f0163ce Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 4 Oct 2016 06:29:25 -0700 Subject: Make it possible to generate PC-relative relocations in data Allow expressions such as: dd bar - $ ... where "bar" is a symbol external to the segment. Currently this is only supported for the Dx instructions; extending it to inline immediates requires additional changes to the parser. This may, however, be sufficient for the needs of some users. Signed-off-by: H. Peter Anvin --- nasm.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'nasm.h') diff --git a/nasm.h b/nasm.h index 663cc21e..0c6478f5 100644 --- a/nasm.h +++ b/nasm.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------- * - * + * * Copyright 1996-2016 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. @@ -14,7 +14,7 @@ * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF @@ -31,7 +31,7 @@ * * ----------------------------------------------------------------------- */ -/* +/* * nasm.h main header file for the Netwide Assembler: inter-module interface */ @@ -546,6 +546,7 @@ typedef struct operand { /* operand to an instruction */ int32_t segment; /* immediate segment, if needed */ int64_t offset; /* any immediate number */ int32_t wrt; /* segment base it's relative to */ + bool relative; /* self-relative expression */ int eaflags; /* special EA flags */ int opflags; /* see OPFLAG_* defines below */ decoflags_t decoflags; /* decorator flags such as {...} */ @@ -553,7 +554,7 @@ typedef struct operand { /* operand to an instruction */ #define OPFLAG_FORWARD 1 /* operand is a forward reference */ #define OPFLAG_EXTERN 2 /* operand is an external reference */ -#define OPFLAG_UNKNOWN 4 /* operand is an unknown reference +#define OPFLAG_UNKNOWN 4 /* operand is an unknown reference * (always a forward reference also) */ @@ -564,6 +565,7 @@ typedef struct extop { /* extended operand */ int64_t offset; /* ... it's given here ... */ int32_t segment; /* if it's a number/address, then... */ int32_t wrt; /* ... and here */ + bool relative; /* self-relative expression */ enum extop_type type; /* defined above */ } extop; @@ -678,7 +680,7 @@ struct ofmt { /* * Output format flags. */ -#define OFMT_TEXT 1 /* Text file format */ +#define OFMT_TEXT 1 /* Text file format */ unsigned int flags; int maxbits; /* Maximum segment bits supported */ -- cgit v1.2.1