summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDelan Azabani <delan@azabani.com>2015-06-01 05:56:11 +0800
committerCyrill Gorcunov <gorcunov@gmail.com>2015-06-02 13:22:32 +0300
commit5b730a197ad343d1e3836feb49888701b9221ade (patch)
tree63d63573121fa04197d2c4d2e999c25ac434bbd6
parent668e58dc692a34ac8df54fa99c9ba28e98c338ff (diff)
downloadnasm-5b730a197ad343d1e3836feb49888701b9221ade.tar.gz
out: maco64 -- Fix erroneously small write for OUT_REL4ADR
Ensure that the int64_t offset value, which ultimately comes from an int64_t value in gencode() (assemble.c:1906), is completely written to the temporary buffer, instead of merely its least significant 32 bits. Prior to this change, WRITELONG was used instead of WRITEDLONG, which resulted in add_reloc being passed an int64_t "reloff" whose least significant 32 bits were those from the aforementioned offset value, and whose most significant 32 bits were stack garbage from "mydata". This led to get_closest_section_symbol_by_offset() attempting to search for extremely large values of "offset" among the symbols in "syms", which meant that the last symbol with a matching section number would always win the symbol search. In effect, this clobbered the resultant relocation information, such that all entries would be resolved with the same symbol. Test output can be found here https://www.azabani.com/patch/2/output.txt This patch fixes http://bugzilla.nasm.us/show_bug.cgi?id=3392306 Signed-off-by: Delan Azabani <delan@azabani.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--output/outmac64.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/output/outmac64.c b/output/outmac64.c
index 1d30e648..461fa326 100644
--- a/output/outmac64.c
+++ b/output/outmac64.c
@@ -588,7 +588,7 @@ static void macho_output(int32_t secto, const void *data,
case OUT_REL4ADR:
p = mydata;
- WRITELONG(p, *(int64_t *)data + 4 - size);
+ WRITEDLONG(p, *(int64_t *)data + 4 - size);
if (section == secto)
nasm_error(ERR_PANIC, "intra-section OUT_REL4ADR");