Skip to content
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: place Darwin bind entries on the __DATA_CONST segment #71416

Open
qmuntal opened this issue Jan 24, 2025 · 2 comments
Open

cmd/link: place Darwin bind entries on the __DATA_CONST segment #71416

qmuntal opened this issue Jan 24, 2025 · 2 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FixPending Issues that have a fix which has not yet been reviewed or submitted. Implementation Issues describing a semantics-preserving change to the Go implementation.
Milestone

Comments

@qmuntal
Copy link
Member

qmuntal commented Jan 24, 2025

#38830 moved the .rodata, .typelink, .itablink, and .gopclntab sections to the __DATA_CONST segment. Looks like the .got section can also go into that new segment. It is currently passed in the __DATA segment.

You can verify that the macOS clang linker already does what I'm suggesting here by following these steps:

  1. Build a hello world binary with go build -ldflags=linkmode=external -o ext
  2. Get the bind table by running objdump --macho --bind ./ext

The result is something like this:

Bind table:
segment  section            address     type       addend dylib            symbol
__DATA_CONST __got              0x100088000 bind ptr        0 libSystem        ___error
__DATA_CONST __got              0x100088008 bind ptr        0 libSystem        ___stderrp
...

While the same binary built with the Go internal linker has the following bind table:

Bind table:
segment  section            address    type       addend dylib            symbol
__DATA   __nl_symbol_ptr    0x1000EC2B0 pointer         0 libSystem        ___error
__DATA   __nl_symbol_ptr    0x1000EC2B8 pointer         0 libSystem        ___stderrp
...

Also note that clang names the.got section as __got on ARM, while we use __nl_symbol_ptr uncoditionally. Don't know if this makes any real difference, but clang made that change consciously in this commit: https://cgit.geodns-americas.gentoo.org/fork/llvm-project.git/commit/?h=release/3.8.x&id=e8d9df4ea52a5652a13f080614507d70e9f9ad79.

Go version:

go version go1.23.3 darwin/arm64

Clang version:

Apple clang version 16.0.0 (clang-1600.0.26.4)

@golang/compiler @golang/darwin

@qmuntal qmuntal added compiler/runtime Issues related to the Go compiler and/or runtime. DevExp anything around developer experience NeedsFix The path to resolution is known, but the work has not been done. labels Jan 24, 2025
@gabyhelp gabyhelp added the Implementation Issues describing a semantics-preserving change to the Go implementation. label Jan 24, 2025
@qmuntal qmuntal removed the DevExp anything around developer experience label Jan 24, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/644055 mentions this issue: cmd/link: put .got section in __DATA_CONST segment

@dmitshur dmitshur added this to the Go1.25 milestone Jan 24, 2025
@dmitshur dmitshur added the FixPending Issues that have a fix which has not yet been reviewed or submitted. label Jan 24, 2025
@qmuntal qmuntal removed the NeedsFix The path to resolution is known, but the work has not been done. label Jan 24, 2025
@mknyszek mknyszek moved this to In Progress in Go Compiler / Runtime Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FixPending Issues that have a fix which has not yet been reviewed or submitted. Implementation Issues describing a semantics-preserving change to the Go implementation.
Projects
Status: In Progress
Development

No branches or pull requests

4 participants