aboutsummaryrefslogtreecommitdiffstats
path: root/asm/assemble.c
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2018-12-13 21:53:31 -0800
committerH. Peter Anvin (Intel) <hpa@zytor.com>2018-12-13 21:53:31 -0800
commit723ab481a6550454a6f834bb854e751744ca340a (patch)
treecb217692a76d3dcab83c7ad922e3adca9006dccd /asm/assemble.c
parent6bde2ed8806b3e53657d46b61ee79d7afe5c2e13 (diff)
downloadnasm-723ab481a6550454a6f834bb854e751744ca340a.tar.gz
nasm-723ab481a6550454a6f834bb854e751744ca340a.tar.xz
nasm-723ab481a6550454a6f834bb854e751744ca340a.zip
warnings: define warning classes at point of usemkwarnings
It is extremely desirable to allow the user fine-grained control of warnings, but this has been complicated by the fact that a warning class has had to be defined in no less than three places (error.h, error.c, nasmdoc.src) before it can be used in source code. Instead, use a script to define these via magic comments at the point of use. This hopefully will encourage creating new classes as needed. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Diffstat (limited to 'asm/assemble.c')
-rw-r--r--asm/assemble.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/asm/assemble.c b/asm/assemble.c
index 964efb0e..03335eb3 100644
--- a/asm/assemble.c
+++ b/asm/assemble.c
@@ -405,7 +405,12 @@ static void out(struct out_data *data)
nasm_nonfatal("%u-bit signed relocation unsupported by output format %s",
(unsigned int)(asize << 3), ofmt->shortname);
} else {
- nasm_warnf(WARN_ZEXTRELOC,
+ /*!
+ *!zext-reloc [on] relocation zero-extended to match output format
+ *! warns that a relocation has been zero-extended due
+ *! to limitations in the output format.
+ */
+ nasm_warnf(WARN_ZEXT_RELOC,
"%u-bit %s relocation zero-extended from %u bits",
(unsigned int)(asize << 3),
data->type == OUT_SEGMENT ? "segment" : "unsigned",
@@ -555,6 +560,15 @@ static bool jmp_match(int32_t segment, int64_t offset, int bits,
if (is_byte && c == 0371 && ins->prefixes[PPS_REP] == P_BND) {
/* jmp short (opcode eb) cannot be used with bnd prefix. */
ins->prefixes[PPS_REP] = P_none;
+ /*!
+ *!bnd [on] invalid BND prefixes
+ *! warns about ineffective use of the \c{BND} prefix when the
+ *! \c{JMP} instruction is converted to the \c{SHORT} form.
+ *! This should be extremely rare since the short \c{JMP} only
+ *! is applicable to jumps inside the same module, but if
+ *! it is legitimate, it may be necessary to use
+ *! \c{BND JMP DWORD}...
+ */
nasm_warnf(WARN_BND | ERR_PASS2 ,
"jmp short does not init bnd regs - bnd prefix dropped.");
}
@@ -904,6 +918,11 @@ static void bad_hle_warn(const insn * ins, uint8_t hleok)
if (!is_class(MEMORY, ins->oprs[0].type))
ww = w_inval; /* HLE requires operand 0 to be memory */
+ /*!
+ *!hle [on] invalid HLE prefixes
+ *! warns about invalid use of the HLE \c{XACQUIRE} or \c{XRELEASE}
+ *! prefixes.
+ */
switch (ww) {
case w_none:
break;
@@ -1398,6 +1417,10 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits,
if (has_prefix(ins, PPS_LOCK, P_LOCK) && lockcheck &&
(!itemp_has(temp,IF_LOCK) || !is_class(MEMORY, ins->oprs[0].type))) {
+ /*!
+ *!lock [on] lock prefix on unlockable instructions
+ *! warns about \c{LOCK} prefixes on unlockable instructions.
+ */
nasm_warnf(WARN_LOCK | ERR_PASS2 , "instruction is not lockable");
}