summaryrefslogtreecommitdiff
path: root/output/outrdf.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-11-13 09:37:59 -0800
committerH. Peter Anvin <hpa@zytor.com>2007-11-13 09:37:59 -0800
commitd1fb15c154b99f9ca8d2356fa9057827b0ab89af (patch)
treee6e95a1979107466eadfad29577e278ee1273890 /output/outrdf.c
parenta5fb90834aa2e849e67bf45b478d498a6cb72062 (diff)
downloadnasm-d1fb15c154b99f9ca8d2356fa9057827b0ab89af.tar.gz
Address data is int64_t; simplify writing an address object
Address data is always int64_t even if the size itself is smaller; this was broken on bigendian hosts (still need testing!) Create simple "write sized object" macros.
Diffstat (limited to 'output/outrdf.c')
-rw-r--r--output/outrdf.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/output/outrdf.c b/output/outrdf.c
index 23e661e5..9c3785bb 100644
--- a/output/outrdf.c
+++ b/output/outrdf.c
@@ -392,16 +392,8 @@ static void rdf_out(int32_t segto, void *data, uint32_t type,
}
pd = databuf; /* convert address to little-endian */
- if (bytes == 4)
- WRITELONG(pd, *(int32_t *)data);
- else if (bytes == 8)
- WRITEDLONG(pd, *(int64_t *)data);
- else
- WRITESHORT(pd, *(int32_t *)data);
-
-
+ WRITEADDR(pd, *(int64_t *)data, bytes);
membufwrite(seg[segto], databuf, bytes);
-
} else if (type == OUT_REL2ADR) {
if (segment == segto)
error(ERR_PANIC, "intra-segment OUT_REL2ADR");
@@ -422,7 +414,7 @@ static void rdf_out(int32_t segto, void *data, uint32_t type,
* address of imported symbol onto it to get address relative to end of
* instruction: import_address + data(offset) - end_of_instrn */
- rr.offset = *(int32_t *)data - (rr.offset + bytes);
+ rr.offset = *(int64_t *)data - (rr.offset + bytes);
membufwrite(seg[segto], &rr.offset, -2);
} else if (type == OUT_REL4ADR) {
@@ -440,7 +432,7 @@ static void rdf_out(int32_t segto, void *data, uint32_t type,
rr.refseg = segment; /* segment referred to */
write_reloc_rec(&rr);
- rr.offset = *(int32_t *)data - (rr.offset + bytes);
+ rr.offset = *(int64_t *)data - (rr.offset + bytes);
membufwrite(seg[segto], &rr.offset, -4);
}
}