cmd/link: handle runtime.type based on size, not GOOS
When handling type descriptors, we add some space at the start
to ensure that offset 0 does not refer to a valid type descriptor.
AIX has an initial runtime.types symbol with a non-zero size,
so we used that instead of adding some space.
In some cases Darwin also has a runtime.types symbol with a non-zero size.
Before CL 727021, this was always fine, because the 8 byte size of
runtime.types was swamped by the 32-byte alignment of type descriptors.
That didn't work for AIX with the external linker, because on AIX the
external linker lays out each symbol separately. Darwin doesn't have
that problem, so the layout of the internal linker was preserved.
However, CL 727021 changed the alignment of type descriptors to 8.
That means that on Darwin the 8 byte size of runtime.types was no
longer hidden by the alignment. In effect we were skipping twice:
once for runtime.types, and then again explicitly. This only failed
when runtime.types has a non-zero size, which is only in a few
specific cases.
This CL cleans this up by not skipping explicitly in any case
where runtime.types has a non-zero size. That handles both AIX
and Darwin consistently.
To make this clearer, I changed the skip from a single byte to
the size of a pointer in all cases.
I considered always giving runtime.types a non-zero size,
but that is a bigger change, and potentially confusing since
there really isn't any data associated with runtime.types.
The cases where we must give it a non-zero size are special,
and I think it's simpler to keep it that way.
For #6853
For #36313
Fixes #77569
Change-Id: I22ebbd0194527ecca96d48849aa00a4fc899e55c
Reviewed-on: https://go-review.googlesource.com/c/go/+/744820 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>