mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-21 03:14:19 +08:00
outmacho: Fix relative relocations for 32-bit Mach-O
IP-relative relocations were broken for 32-bit Mach-O when referencing external symbols after the Mach-O backends were merged. This fixes bug reports 3392348, 3392352, and 3392346. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
parent
ccb16787d5
commit
84f6860ed5
@ -465,6 +465,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 if (reltype == GENERIC_RELOC_VANILLA)
|
||||
adjust = -sect->size;
|
||||
} else {
|
||||
/* local */
|
||||
r->ext = 0;
|
||||
@ -1321,6 +1323,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 */
|
||||
|
Loading…
Reference in New Issue
Block a user