summaryrefslogtreecommitdiff
path: root/output/outrdf2.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2013-11-26 18:09:56 -0800
committerH. Peter Anvin <hpa@zytor.com>2013-11-26 18:12:39 -0800
commitfd52c277dd6d768545cee39b154e706904581966 (patch)
tree57ffb4113bc8871ca3679ae765c92a1076efa297 /output/outrdf2.c
parent80d18b55551e43f0c3e390550ecd396b90265fd3 (diff)
downloadnasm-fd52c277dd6d768545cee39b154e706904581966.tar.gz
output: Allow OUT_ADDRESS with a negative size to mean signed relocation
This only matters for ELF64/ELFx32, at least for now. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'output/outrdf2.c')
-rw-r--r--output/outrdf2.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/output/outrdf2.c b/output/outrdf2.c
index 02518a1a..c7aeb28b 100644
--- a/output/outrdf2.c
+++ b/output/outrdf2.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2009 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2013 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -583,6 +583,7 @@ static void rdf2_out(int32_t segto, const void *data,
membufwrite(segto, data, size);
} else if (type == OUT_ADDRESS) {
+ int asize = abs(size);
/* if segment == NO_SEG then we are writing an address of an
object within the same segment - do not produce reloc rec. */
@@ -597,14 +598,14 @@ static void rdf2_out(int32_t segto, const void *data,
rr.reclen = 8;
rr.segment = segto; /* segment we're currently in */
rr.offset = getsegmentlength(segto); /* current offset */
- rr.length = size; /* length of reference */
+ rr.length = asize; /* length of reference */
rr.refseg = segment; /* segment referred to */
write_reloc_rec(&rr);
}
pd = databuf; /* convert address to little-endian */
- WRITEADDR(pd, *(int64_t *)data, size);
- membufwrite(segto, databuf, size);
+ WRITEADDR(pd, *(int64_t *)data, asize);
+ membufwrite(segto, databuf, asize);
} else if (type == OUT_REL2ADR) {
if (segment == segto)
nasm_error(ERR_PANIC, "intra-segment OUT_REL2ADR");