summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-10-22 11:15:00 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-10-22 11:15:00 -0700
commite286c7e79c36ab0ad40349d89693bae52080b664 (patch)
tree2bf79243c0fd4d62c059bf4a19224ee3b5b6d129
parent9cd543e5fd6616f3c7b4de641247a419f0435527 (diff)
downloadnasm-e286c7e79c36ab0ad40349d89693bae52080b664.tar.gz
assemble: not all backends handle intra-segment OUT_REL*ADR
Not all backends can handle being handled an intrasegment OUT_REL*ADR, and we don't fix them up in common code either (which would be the logical thing to do -- right now we fix them up in a bunch of individual places.) For now, just fix up the one in address generation. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--assemble.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/assemble.c b/assemble.c
index dfc83a05..aea3a5e8 100644
--- a/assemble.c
+++ b/assemble.c
@@ -1811,10 +1811,17 @@ static void gencode(int32_t segment, int64_t offset, int bits,
warn_overflow(ea_data.bytes, opx);
s += ea_data.bytes;
if (ea_data.rip) {
- out(offset, segment, &data,
- OUT_REL4ADR, insn_end - offset,
- ins->oprs[(c >> 3) & 7].segment,
- ins->oprs[(c >> 3) & 7].wrt);
+ if (ins->oprs[(c >> 3) & 7].segment == segment) {
+ data -= insn_end;
+ out(offset, segment, &data,
+ OUT_ADDRESS, ea_data.bytes,
+ NO_SEG, NO_SEG);
+ } else {
+ out(offset, segment, &data,
+ OUT_REL4ADR, insn_end - offset,
+ ins->oprs[(c >> 3) & 7].segment,
+ ins->oprs[(c >> 3) & 7].wrt);
+ }
} else {
type = OUT_ADDRESS;
out(offset, segment, &data,