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:
Zenith432 2016-05-09 11:16:10 -07:00 committed by H. Peter Anvin
parent ccb16787d5
commit 84f6860ed5

View File

@ -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 */