-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/link: use __DATA_CONST on darwin? #38830
Comments
I think __rodata, __typelink, __itablink, and __gopclntab can go there. These are read-only data sections currently in __TEXT, or __DATA (for PIE binaries and a few configurations). The question is, is it only supported in newer version of macOS and/or newer version of darwin linker? We probably still need to do the old way to support old platforms. |
Sierra came out a year after iOS 9 so I assume we're good to use it unconditionally at this point. |
At first glance the new section sounds identical to ELF's relro section, which cmd/link already supports. |
Yeah, I believe the linker already has the relevant bits. It's probably just a matter of where to put those sections. |
cc @mwhudson too, as there's a TODO in the code: // TODO(mwhudson): It would make sense to do this more widely, but it makes
// the system linker segfault on darwin.
addrelrosection := func(suffix string) *sym.Section {
return addsection(ctxt.Arch, segro, suffix, 04)
} Is that darwin segfault referring to __DATA_CONST? |
Honestly I have no idea any more. That comment is from May 2015 though, which is slightly before iOS 9 -- so I suspect it must have been something else. |
Change https://golang.org/cl/253918 mentions this issue: |
Change https://golang.org/cl/253919 mentions this issue: |
Change https://golang.org/cl/253921 mentions this issue: |
…nly data Updates #38830. Change-Id: I826c6b0a42bc8e48fcda556250ca4a95c73987eb Reviewed-on: https://go-review.googlesource.com/c/go/+/253918 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
Updates #38830. Change-Id: Ie1f6ccef40a773f038aac587dfc26bf70a1a8536 Reviewed-on: https://go-review.googlesource.com/c/go/+/253921 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Recent iOS/macOS (starting at iOS 9?) support a new segment __DATA_CONST:
https://developer.apple.com/documentation/xcode_release_notes/xcode_11_release_notes?language=objc
Other information online suggests that such segments don't contribute to the memory limit of processes on iOS, as they can always be paged in from disk.
Are there any Go sections that could go in that segment?
On a macOS binary now (with
-ldflags=-w
), I see:I know relatively little about linkers but see no reference to __DATA_CONST in Go's tree, and see other projects online that have added __DATA_CONST support, so was curious if it's applicable for Go.
/cc @ianlancetaylor @cherrymui @thanm @jeremyfaller @aclements (people who seem to know linkers)
The text was updated successfully, but these errors were encountered: