macos: Fix GOT access to local defined symbols
commitfab8787b23643f108eec81add8252b3d65582590
authorMichael Matz <matz@suse.de>
Sun, 17 May 2020 02:39:40 +0000 (17 04:39 +0200)
committerMichael Matz <matz@suse.de>
Sat, 20 Jun 2020 20:12:02 +0000 (20 22:12 +0200)
treee745f65bfeda2ef81f40801b0533630382cb51bc
parent6ebd463021d127dddba5b27140ff2b421675b11f
macos: Fix GOT access to local defined symbols

if a GOT slot is required (due to codegen, indicated by
presence of some relocation types), then it needs to contain
the address of the wanted symbol, also when it's local and defined,
i.e. not overridable.  For simplicity we use a GOT slot for that as
well (other storage would require rewriting relocs and symbols,
as resolving of GOT relocs is hardwired to be based on s1->got).
But that means we need to fill in its indirect symbol mapping slot as
well, for which Mach-O provides a mean to say "not symbol based,
resolved locally".  So this fixes this testcase:

static int loc;
int _start(void)
{
  loc = 42;
  return loc - 42;
}

(where our codegen currently uses a GOT-based access for the write
by accident)
tccmacho.c