diff options
| author | Cherry Mui <cherryyz@google.com> | 2024-06-11 18:39:19 -0400 |
|---|---|---|
| committer | Cherry Mui <cherryyz@google.com> | 2024-06-12 15:10:50 +0000 |
| commit | b589478af7f4b09cc9c4d5f76fbbf5cad2b2b7bb (patch) | |
| tree | fdf497366e93c16f2fe780b5cfea86249bb72aff /src/cmd/link | |
| parent | b788e91badd523e5bb0fc8d50cd76b8ae04ffb20 (diff) | |
| download | go-b589478af7f4b09cc9c4d5f76fbbf5cad2b2b7bb.tar.xz | |
cmd/link: put runtime.end in the last section of data segment
Currently the runtime.end symbol is put into the noptrbss section,
which is usually the last section, except that when fuzzing is
enabled, the last section is actually .go.fuzzcntrs. The
runtime.end symbol has the value pointing to the end of the data
segment, so if it is not in the last section, the value will not
actually be in the range of the section. This causes an assertion
failure in the new Apple linker. This CL fixes this by putting it
in the last section.
Fixes #65169.
Change-Id: I5c991c46a0483a96e5f6e0255a3b444953676026
Reviewed-on: https://go-review.googlesource.com/c/go/+/592095
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/link')
| -rw-r--r-- | src/cmd/link/internal/ld/data.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index 1e221d090a..b18dc6993b 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -1918,7 +1918,6 @@ func (state *dodataState) allocateDataSections(ctxt *Link) { sect = state.allocateNamedSectionAndAssignSyms(&Segdata, ".noptrbss", sym.SNOPTRBSS, sym.Sxxx, 06) ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.noptrbss", 0), sect) ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.enoptrbss", 0), sect) - ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.end", 0), sect) // Code coverage counters are assigned to the .noptrbss section. // We assign them in a separate pass so that they stay aggregated @@ -1938,6 +1937,9 @@ func (state *dodataState) allocateDataSections(ctxt *Link) { ldr.SetSymSect(ldr.LookupOrCreateSym("internal/fuzz._ecounters", 0), sect) } + // Assign runtime.end to the last section of data segment. + ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.end", 0), Segdata.Sections[len(Segdata.Sections)-1]) + if len(state.data[sym.STLSBSS]) > 0 { var sect *sym.Section // FIXME: not clear why it is sometimes necessary to suppress .tbss section creation. |
