From: Zenith432 <zen...@us...> - 2016-04-28 10:35:55
|
Attached is a patch to fix http://bugzilla.nasm.us/show_bug.cgi?id=3392348 that I filed. The patch is relative to git commit 3421a3f3f34a9b6c4edef69e40dc1b38d58dade3 dated Sun, 24 Apr 2016 20:57:52 +0300 -------------------- begin patch diff a/output/outmacho.c b/output/outmacho.c --- a/output/outmacho.c +++ b/output/outmacho.c @@ -464,6 +464,8 @@ static int64_t add_reloc(struct section *sect, int32_t section, r->snum = raa_read(extsyms, section); if (reltype == RL_BRANCH) r->type = X86_64_RELOC_BRANCH; + else + adjust = -sect->size; } else { /* local */ r->ext = 0; -------------------- end patch I tested it on the sample program I provided with 3392348, and assembled with 3 variants of NASM 1) nasm v2.12.01 OS X binary as published on nasm.us. 2) Apple's nasm that comes with Xcode 7.3, and is versioned as NASM version 0.98.40 (Apple Computer, Inc. build 11) compiled on Feb 10 2016 3) nasm complied from source of commit 3421a3f3f patched with patch above. Apple's nasm, and patched nasm both give the same result in .o file (assembled with -f macho, or -f macho32). The published binary of v2.12.01 gives a wrong result as explained in bug 3392348. I believe this patch also solves bug 3392346, which is probably due to the same problem, but there's not enough information in the bug description to be sure. Regards. |