aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2026-02-11 21:23:49 -0800
committerGopher Robot <gobot@golang.org>2026-02-12 06:08:58 -0800
commit20bc1949722c1fd66de5d568f1422845332d18f3 (patch)
tree8e2a5ffaabbca019ae0c3876f74310c3c4aaf991 /src/runtime
parentb40f0b118014f8dbc25e8ef4de82ccf78410903f (diff)
downloadgo-20bc1949722c1fd66de5d568f1422845332d18f3.tar.xz
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>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/type.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/runtime/type.go b/src/runtime/type.go
index 1abd271c3f..58349e921a 100644
--- a/src/runtime/type.go
+++ b/src/runtime/type.go
@@ -524,14 +524,15 @@ func moduleTypelinks(md *moduledata) []*_type {
td := md.types
- // We have to increment by 1 to match the increment done in
- // cmd/link/internal/data.go createRelroSect in allocateDataSections.
+ // We have to increment by the pointer size to match the
+ // increment in cmd/link/internal/data.go createRelroSect
+ // in allocateDataSections.
//
- // We don't do that increment on AIX, but on AIX we need to adjust
- // for the fact that the runtime.types symbol has a size of 8,
- // and the type descriptors will follow that. This increment,
- // followed by the forced alignment to 8, will do that.
- td++
+ // The linker doesn't do that increment when runtime.types
+ // has a non-zero size, but in that case the runtime.types
+ // symbol itself pushes the other symbols forward.
+ // So either way this increment is correct.
+ td += goarch.PtrSize
etypedesc := md.types + md.typedesclen
for td < etypedesc {