From: Zenith432 <zen...@us...> - 2016-04-29 08:23:06
|
I hope this time I got it right.... Previous patch does not work for sections containing instructions other than the .text section. Here's another try, and I think this is it. =========== 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; + if (r->type == GENERIC_RELOC_VANILLA) + adjust = -sect->size; } else { /* local */ r->ext = 0; @@ -1320,6 +1322,8 @@ static void macho_write_section (void) l += sectstab[r->snum]->addr; if (r->pcrel) l -= s->addr; + } else if (r->pcrel && r->type == GENERIC_RELOC_VANILLA) { + l -= s->addr; } /* write new offset back */ =========== end patch Attached are also 1) test32.nasm and test64.nasm designed to do a comprehensive test of pc-relative relocations. 2) sample_disasm.txt of what a disassembly by 'otool -jV' should look like. |