aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal
AgeCommit message (Collapse)Author
31 hoursall: prealloc slice with possible minimum capabilitiesShulhan
6 dayscmd/link: fallback to older minimum Windows target version on older C GNU ↵qmuntal
toolchains Setting Windows 10 as the minimum target version requires setting the IMAGE_GUARD_SECURITY_COOKIE_UNUSED flag in the PE load config directory, else the executable will fail to run. When using an external linker that flag is set by defining a _load_config_used symbol with the proper value. However, older versions of the GNU toolchain do not associate the _load_config_used symbol with the PE load config directory. To work around this issue, we can fallback to the previous minimum Windows target version if the external linker doesn't special-case the _load_config_used symbol. Change-Id: I36ac7a2968c3576ac788bf192e7614bbae35ad1f Reviewed-on: https://go-review.googlesource.com/c/go/+/763960 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2026-04-01cmd/link: make dupok symbol handling path clearerCherry Mui
When the linker sees two symbols with the same name, if both are dupok, pick the one with larger size. If one is dupok, one is not, pick the one that is not dupok, as "dupok" is sort of like weak symbol in C terms. Change-Id: I0a95d1ddfdd70ffb5ecc06645fb345591039af49 Reviewed-on: https://go-review.googlesource.com/c/go/+/749943 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-04-01cmd/compile, cmd/link: add linknamestd directive for std-only linknamesCherry Mui
In the standard library, there are a number of linknames, for sharing symbols within the standard library. They are not supposed to be accessed externally. But currently there is no good mechanism to prevent that. In the linker we have a blocklist of linknames, which forbids linkname references other than explicitly allowed packages. The blocklist is manually maintained, requiring periodic manual update. To move away from that manually maintained blocklist, this CL introduces a new directive, linknamestd, that marks a linkname for use within the standard library only. The linker will allow references within the standard library and forbid others. For a proof of concept, runtime.coroswitch is removed from the blocklist, and replaced with linknamestd. An external reference to it is still disallowed by the linker, as tested with cmd/link.TestCheckLinkname with testdata/linkname/coro.go. Change-Id: I0d0f8746b8835d8cdcfc3ff835d22a551da5f038 Reviewed-on: https://go-review.googlesource.com/c/go/+/749942 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2026-04-01cmd/link: remove SITABLINKIan Lance Taylor
As of CL 729201 it's no longer used. Change-Id: Idc3104208d160e657f6dbef99c8124cd760c3c77 Reviewed-on: https://go-review.googlesource.com/c/go/+/745960 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2026-03-31cmd/link/internal/loong64: remove the handling of R_CONST and R_GOTOFF from ↵limeidan
linker These two relocations are general relocations and do not require special architectural handling. Change-Id: Ibd5e71f6337e8dbb68e84759a46a46d9843b0382 Reviewed-on: https://go-review.googlesource.com/c/go/+/760080 Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-31cmd/link, runtime: record size of itabsIan Lance Taylor
We were depending on runtime.etypes immediately following the itabs. However, on AIX, runtime.etypes, as a zero-sized symbol, can float when using external linking. It won't necessarily stay right at the end of the itabs. Rather than worry about this, just record the size of the itab data. In practice it almost always works on AIX, but it fails the runtime test TestSchedPauseMetrics/runtime/debug.WriteHeapDump, which fails when iterating over all the itabs. Tested on AIX. This should fix AIX on the build dashboard. Change-Id: Id3a113b75b93fa8440c047e92f764ab81423df48 Reviewed-on: https://go-review.googlesource.com/c/go/+/760203 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
2026-03-27all: remove openbsd/mips64 portTobias Klauser
The openbsd/mips64 port is dead, remove the remaining code specific to that port and clean up build tags. Fixes #61546 Change-Id: I0328b7b76ce1ddacd3a526b3f4ae29eaa1254c3f Reviewed-on: https://go-review.googlesource.com/c/go/+/746480 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Joel Sing <joel@sing.id.au> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2026-03-26cmd/link: group gcmask symbols, move them to noptrbssIan Lance Taylor
Also take them out of the symbol table. A new symbol runtime.gcmask.* marks where they start in BSS, and can be used to find them if anybody cares. Also stop checking for gcprog symbols that we no longer define. Change-Id: I4060d8e9350c20568f020172caacd0439337cd2d Reviewed-on: https://go-review.googlesource.com/c/go/+/729880 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2026-03-26runtime, cmd/link: remove itablinksIan Lance Taylor
Instead of keeping a separate list of pointers to itabs, just walk through the itabs themselves. For #6853 Change-Id: If030bd64fbd01d73b0bf8495f6c9826ed2e61568 Reviewed-on: https://go-review.googlesource.com/c/go/+/729201 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-03-25cmd/link: fix host object's .pdata entries orderqmuntal
Host objects are expected to have their .pdata entries in the correct order, but the Go internal linker might reorder some of the functions associated with the .pdata entries. This causes the .pdata section in the final binary to have entries in the wrong order, and therefore issues with unwinding on Windows. The fix is to treat the .pdata entries of host objects as individual symbols that will be retained only if the function they are associated with is retained. Also, those entries will be sorted together with the .pdata entries emitted by the Go compiler, ensuring the correct order in the final binary. Fixes #65116 Change-Id: I421471b2aef519b0c20707a40c4b7957db5d2ed5 Reviewed-on: https://go-review.googlesource.com/c/go/+/754080 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-03-24internal/abi, cmd/link: centralize type descriptor size calculationJake Bailey
The linker hardcoded the calculation for some types, which caused me some annoyance in CL 711560 because I didn't know it needed to be updated (and it took me a long time to find the hardcoded value). Move this calculation over to the abi package, similar to other funcs. Then update rttype.Init to also check that the function works, like again like other funcs in this package. This actually caught a latent bug; decodetypeMethods was incorrectly calculating the size for the Interface case! Change-Id: Iaa66055061b68ec93c9912ae6aa6e605260f52a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/749961 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-03-24internal/runtime/maps: add GOEXPERIMENT=mapsplitgroup for KKKKVVVV slot orderJake Bailey
Map groups are currently: type group struct { ctrl uint64 slots [8]slot } type slot struct { key K elem E } If the element type is struct{}, the slot will be padded so that the address of the elem is unique rather than pointing outside the alloc. This has the effect of map[K]struct{} wasting space due to the extra byte and padding, making it no better than map[K]bool. This CL changes the group layout to instead place keys and elems together, as they used to be before swiss maps: type group struct { ctrl uint64 keys [8]K elems [8]V } This is an alternative to CL 701976, which I suspect will have better performance. Keys placed together should lead to better cache behavior, at the cost of more expensive elem lookups, since the elems are not a fixed offset from their keys. This change is locked behind GOEXPERIMENT=mapsplitgroup. Updates #70835 Updates #71368 Change-Id: Ide8d1406ae4ab636f86edc40e0640cc80653197c Reviewed-on: https://go-review.googlesource.com/c/go/+/711560 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-03-24cmd/link: raise minimum windows version to 10Jason A. Donenfeld
The minimum Windows version has been 10 for a few releases, but the PE headers weren't updated. Windows sometimes can use these in determining what kind of subsystem compatibility hacks to apply, which of course we don't want now, since Go targets Windows 10. This also causes older OSes to refuse to run the executables, rather than having them crash in some undefined way. This isn't trivial to do, because subsystem ≥ 10.0 means that the Windows loader expects to see either _load_config_used.SecurityCookie set to the initial magic value, or for IMAGE_GUARD_SECURITY_COOKIE_UNUSED to be set. Go obviously isn't making use of these features, and neither does clang/gcc for that matter; libssp doesn't even use SecurityCookie. Rather, it's exclusively for MSVC's /GS protection. So it seems like the proper thing to do is signal to the OS that it doesn't need to initialize SecurityCookie. This check lives in ntdll!LdrInitSecurityCookie. So, add the _load_config_used structure to the right PE section and give it the right flag. This lets the Windows 10-marked binaries actually run. Change-Id: I91887073c7ad01aeb0237906aafa4ea5574ac8fa Reviewed-on: https://go-review.googlesource.com/c/go/+/756680 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Jason Donenfeld <Jason@zx2c4.com> Reviewed-by: Jason Donenfeld <Jason@zx2c4.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-22cmd/link/internal/loong64: remove the handling of R_CONST and R_GOTOFF from ↵limeidan
the internal linker These two relocations are already handled in general code and do not require architecture-specific processing. Change-Id: Ibf29af1a8b45c0ce4c40061524f9f7dda4edfff3 Reviewed-on: https://go-review.googlesource.com/c/go/+/756280 Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-03-19cmd/link: propagate Mach-O section alignment to symbol in loadmachopenglei
The Mach-O object file loader reads the section alignment from the section header into ldMachoSect.align, but never calls SetAlign on the symbol builder when converting sections to linker symbols. This causes all Mach-O .syso sections to fall back to Funcalign (16 bytes on ARM64) regardless of the alignment declared in the section header. For .syso files containing C-compiled code with ADRP instructions on ARM64, the lack of page alignment (4096 bytes) leads to incorrect PC-relative address computation and runtime crashes. The ELF loader already correctly propagates section alignment via sb.SetAlign (ldelf.go:543). Apply the same treatment to the Mach-O loader. Note that Mach-O stores alignment as log2 (e.g. 12 for 4096), so we use 1 << sect.align. Fixes #78192 Change-Id: Icae22be2dc726d56eaa35825b484d04ed18566f2 GitHub-Last-Rev: 85aa42b59a663335b3ce72f7b60ffa240aadeff8 GitHub-Pull-Request: golang/go#78194 Reviewed-on: https://go-review.googlesource.com/c/go/+/756000 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-03-19cmd/link: skip special symbols for label symbol generationCherry Mui
Some special symbols, e.g. funcdata symbols, don't have a section set, because they are laid out as part of the top-level go:func.* symbol. Similarly, other non-top-level symbols are part of some top-level symbols. There is no relocation directly targetting those symbols, so there is no need to generate label symbols for them. Fixes #77593. (No in-tree test as it needs a function with very large funcdata.) Change-Id: I4aac4d0438bd64ac60b9baa3c2c66bb11f03c404 Reviewed-on: https://go-review.googlesource.com/c/go/+/756060 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-03-18cmd/link/internal/loong64: add immediate range detection to the internal linkerlimeidan
Change-Id: If535d843318e5a16584eabd7df2d2fdd04896965 Reviewed-on: https://go-review.googlesource.com/c/go/+/754980 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn>
2026-03-18cmd/link: work around race syso weak import on macOSCherry Mui
With https://github.com/llvm/llvm-project/pull/182943, the race detector syso has a weak import of __dyld_get_dyld_header, which is only defined on newer macOS (26.4+). For external linking with a pre-Xcode 26.4 C toolchain, we need to tell the C linker to permit that symbol not being defined. Pass a flag to do so. Change-Id: I95a3cd2c7fd3ad50bc47985b3ecca0d4e8352162 Reviewed-on: https://go-review.googlesource.com/c/go/+/755261 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Lasse Folger <lassefolger@google.com>
2026-03-18cmd/link: modify the register used in trampolinelimeidan
R30 is the callee's saved register; using it requires saving and then restoring. Therefore, we replace it with a register saved by the caller. R4~R19 are argument registers on loong64, and R20 is the only remaining usable caller saved register. To use R20 in trampoline, we modified the registers used by the LoweredMove/LoweredMoveLoop operations (originally using r20 and r21, now changed to R23 and R24). Change-Id: Ie7bba0caa30a764a45bcb47635c35c829036c5a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/726140 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-03-18cmd/link: support loading R_LARCH_GOT64_PC_{LO12, HI20} relocs on loong64Guoqi Chen
On loong64, such relocations are increasingly common when built using an "extreme" code model. To ensure future interoperability with cgo, the linker needs to be made aware of these relocations. Ref: https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc Fixes #78047. Change-Id: Ibca205ab837279c69fb243a8e8519c952e11c99e Reviewed-on: https://go-review.googlesource.com/c/go/+/753521 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2026-03-13cmd/link: use 13.0.0 OS version for macOS linkingDmitri Shuralyov
Go 1.27 will require macOS 13 Ventura or later, so macOS 12 will be unsupported. For #75836. For #77944. Change-Id: I66f858438965c9836d647198d50acf4ca345e498 Reviewed-on: https://go-review.googlesource.com/c/go/+/754620 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2026-03-11cmd/link: fix macOS 13 buildRuss Cox
Write our own load command for macOS builds, to make sure we can put the versions in. Builds on older macOS were seeing an LC_VERSION_MIN instead and scribbling over fields that didn't exist. Fixes #78070. Change-Id: If338d0506b1156b133253e496f29818a29a22a91 Reviewed-on: https://go-review.googlesource.com/c/go/+/754241 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Russ Cox <rsc@golang.org>
2026-03-10cmd/link: add -macos and -macsdk flags to set LC_BUILD_VERSIONRuss Cox
These are for debugging problems with the build versions in the load commands. We still want to set them correctly by default for most users, provided we can determine what that means. Fixes #58722. Change-Id: Iccab7044ac7b0c58e7e01258a5e374c4155528fc Reviewed-on: https://go-review.googlesource.com/c/go/+/751260 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-03-10cmd/link: put itabs in the .go.type sectionIan Lance Taylor
For #76038 Change-Id: I4c30d5854fcaacc7fd7f84b4679a5be30379122d Reviewed-on: https://go-review.googlesource.com/c/go/+/729200 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Pagol Mon <mpagol707@gmail.com>
2026-03-06cmd/link: sort .pdata by function start addressqmuntal
Loosely based on CL 678795. The PE/COFF spec requires RUNTIME_FUNCTION entries in the .pdata section to be ordered by their function start address. Previously the linker emitted them in symbol order. An unsorted table triggers the MSVC linker error: fatal error LNK1223: invalid or corrupt file: file contains invalid .pdata contributions Fixes #65116. Change-Id: I589cb4e6787a9edb34400b56e60fe23065b59162 Reviewed-on: https://go-review.googlesource.com/c/go/+/743820 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2026-03-06cmd/link: allow -no family of flags for testing compiler flagCorentin Kerisit
This changes modifies Go to allow the -nostdlib++ flag to the list of allowed flags to be passed to the c compiler invocation when testing flags in cmd/link. It is similar to #76858 and complements #76825. This is needed for hermetic c only toolchains where -nostdlib++ is passed transitively. Given prior discussions about security considerations when adding flags to the whitelist, this particular one may be particularly safe to whitelist. Change-Id: If2e295f9de544b4498ad37fb07d3f7b3b11bbf6d GitHub-Last-Rev: e59fd659d7e7e2e057bbb29e5ae12b0fa11fdb60 GitHub-Pull-Request: golang/go#77601 Reviewed-on: https://go-review.googlesource.com/c/go/+/745340 Reviewed-by: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-04cmd/link: support Mach-O UNSIGNED relocations for dynamic imports on darwinGeorge Adams
When internally linking darwin binaries, the linker rejected Mach-O UNSIGNED (pointer) relocations targeting dynamic import symbols, producing errors like: unexpected reloc for dynamic symbol _swift_FORCE_LOAD_$_swiftIOKit These relocations are legitimate and appear in data sections (e.g. __DATA/__const) of object files that reference external symbols such as Swift force-load symbols. The dynamic linker (dyld) needs to bind these pointers at load time. Cq-Include-Trybots: luci.golang.try:gotip-darwin-arm64_15,gotip-darwin-amd64_14 Change-Id: I1cc759dec28b8aa076602a45062f403d0d9f45fe Reviewed-on: https://go-review.googlesource.com/c/go/+/745220 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2026-03-02all: test: remove unneeded loop variablesAriel Otilibili
This CL follows from the abandoned CL 722961. Alan Donovan asked if modernize would catch these changes; it does in part. Here is how modernize was used: 1. Build the Go compiler from latest master 2. Clone x/tools and build modernize with the newest compiler 3. Then, do: PATH=PATH_TO_BIN:$PATH go list ./... | xargs env PATH=PATH_TO_BIN:$PATH GOMOD=off MODERNIZE -forvar -fix -test -debug fpstv 4. For assurance, move into a package directory (i.e, cmd), and redo Step 3. From the obtained result, it seems modernize did not remove the loop variable when: - the range notation was not used - the loop variable was not directly under the for directive. Which does happens here: # git ls-files | xargs -I {} perl -nE 'print "$ARGV:$.:$_" if /\s+(\w+) := \1$/' {} | grep _test [...] cmd/compile/internal/types2/api_test.go:2423: i := i md/go/internal/modload/query_test.go:182: tt := tt md/go/internal/web/url_test.go:17: tc := tc cmd/go/internal/web/url_test.go:49: tc := tc cmd/internal/par/queue_test.go:54: i := i runtime/syscall_windows_test.go:781: arglen := arglen Link: https://go-review.googlesource.com/c/go/+/722961/comments/e8d47866_fc399fa1 Co-authored-by: Plamerdi Makela <plamerdi447@gmail.com> Fixes #76411 Change-Id: I0c191cdca70dbea6efaf6796dca9c60e2afcd9ea GitHub-Last-Rev: 77c3e11fc21a4ede70b733b567a1690edb944dc1 GitHub-Pull-Request: golang/go#77694 Reviewed-on: https://go-review.googlesource.com/c/go/+/746502 Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2026-02-27cmd/link, cmd/internal: remove the R_JMPLOONG64 relocation of loong64limeidan
R_JMPLOONG64 and R_CALLLOONG64 have the same functionality, and R_JMPLOONG64 is not used. Change-Id: Id6ac0bfa67025de45f9c51349931142d945134d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/748340 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: David Chase <drchase@google.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-02-19cmd/link: use bfd ld 2.36+ on linux/arm64 instead of goldDimitri John Ledkov
The bfd linker has been fixed for a while. In the mean time gold got deprecated and has stopped receiving new features. Add runtime version checking and only use gold, if bfd ld 2.35 and lower is detected. This enables using `-buildmode=shared` on arm64 without installing binutils-gold (on distributions that split package this), as well as to use external ldflags that ld.bfd supports, and ld.gold does not. For example, this enables to specify gcs-report-dynamic=none when building with GCC-15. Fixes #22040. Change-Id: I4eb8b3dabb78844ff662332ad63a4625278271b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/740480 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Cherry Mui <cherryyz@google.com>
2026-02-17all: use LF line ending for C filesCherry Mui
For Go files, gofmt already converts CRLF line ending to LF. For C and assembly files, we don't enforce a format, but most files in tree are written with LF line ending, and the C toolchain can handle them file, even on Windows. Convert all to LF line ending for consistency. Will look into adding a test for them. Updates #9281. Change-Id: Idc0dc13f0ab90b8cd8ea118abf9cb195ec438fe7 Reviewed-on: https://go-review.googlesource.com/c/go/+/746220 Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-13cmd/link: support PIE on linux/s390x without cgoGeorge Adams
Enable PIE builds on linux/s390x when CGO is disabled by teaching the linker to handle dynamic relocations against SDYNIMPORT symbols. This adds support for TLS_IE and handles R_CALL, R_PCRELDBL, and R_ADDR relocations by generating the appropriate PLT/GOT entries instead of rejecting them as unsupported. Fixes #77449 Cq-Include-Trybots: luci.golang.try:gotip-linux-s390x Change-Id: Ib6586780073fedbcbd42b9a2c554a99dd7386aa6 Reviewed-on: https://go-review.googlesource.com/c/go/+/742342 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-12cmd/link: handle runtime.type based on size, not GOOSIan Lance Taylor
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>
2026-02-11cmd/link: correct libc dynamic linker pathMeng Zhuo
Ref: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/114 Fixes #77209 Change-Id: I8b575a95ad4e6a7e792514d7fcf9497599c1e404 Reviewed-on: https://go-review.googlesource.com/c/go/+/737180 Reviewed-by: Pengcheng Wang <wangpengcheng.pp@bytedance.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> TryBot-Bypass: Meng Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2026-02-06cmd/link: only run ELF tests on ELF systemsIan Lance Taylor
Running these tests on other systems is a pointless waste of time. This runs cmd/link/internal/ld/elf_test.go in the same cases that we run cmd/link/elf_test.go. Change-Id: I318fb5c2de9e4cfdb976bc2389c72cede6661b47 Reviewed-on: https://go-review.googlesource.com/c/go/+/740782 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-06cmd/link: use correct alignment for type descriptors on AIXIan Lance Taylor
CL 724261 changed the linker to put all type descriptors that are used for typelinks in a single list. This caused trouble on AIX when linking externally, because the AIX linker aligns symbols individually, rather than honoring the layout of the object file generated by the internal linker. I fixed internal linking problems with CL 740220, but that just made things worse for the external linker. This CL rolls back 740220, and adds commentary. With this CL we force a smaller alignment for type descriptors, use the same alignment for runtime.types and type:*, and use a consistent size for runtime.types in all cases. With this change all the type descriptor related code passes again on AIX, except for the new TestTypePlacement test which I will fix in a followup CL. Fixes #77400 Change-Id: I9f25847eb0588001cb4ce453f211a655400d6a59 Reviewed-on: https://go-review.googlesource.com/c/go/+/740820 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-06cmd/link: align covctrs symbolKeith Randall
If we start the covctrs blob at an odd alignment, then covctrs will not be correctly aligned. Each individual entry is aligned properly, but the start marker may be before any padding inserted to enforce that alignment. Fixes #58936 Change-Id: I802fbe40eacfa5a3c8c4864e078b0e078da956d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/733740 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@google.com>
2026-02-06cmd/link: ignore GCC generated .wm4/.wm8 symbols with no typeIan Lance Taylor
Fixes #77436 Change-Id: I37d852a89678c929156c4765e774c819eb515e6f Reviewed-on: https://go-review.googlesource.com/c/go/+/742220 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2026-02-06cmd/link: correct error message in loadelf.LoadIan Lance Taylor
The message said we were ignoring the symbols, but we aren't. We are treating them as an error. For #77436 Change-Id: I5492d81717c539b09f6956b591178f1f3a42893d Reviewed-on: https://go-review.googlesource.com/c/go/+/742060 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-05cmd/link: add more clang driver flags when testing flagCorentin Kerisit
This changes does 2 things: - Move `-L` to `prefixesToKeep` since it allows providing a custom default libs search path. - Allow various flags that impact the behaviour of the clang driver. The latter allows for LLVM only toolchains to be compatible with linkerFlagSupported checks. The end goal of this PR is to allow fully hermetic toolchains, especially pure LLVM ones, to be used to cross-compile CGO. Fixes #76825 Change-Id: I2311c9566ce9c7e8f6b325258af58eb333663cf0 GitHub-Last-Rev: 74342aae35124cf174a3f8b888999ffd4cea191f GitHub-Pull-Request: golang/go#76858 Reviewed-on: https://go-review.googlesource.com/c/go/+/730561 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2026-02-04cmd/link: remove obsolete duffzero/duffcopy codeKeith Randall
Change-Id: Icf94808a6c137c3c114a0be1f8da85ee5f68d58e Reviewed-on: https://go-review.googlesource.com/c/go/+/740740 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2026-01-30all: switch linux-ppc64 target to ELFv2 ABIPaul Murphy
Go is only capable of producing internally linked, static binaries on linux-ppc64. As such, binaries should run in either ELFv1 or ELFv2 ppc64 userspaces today. This opens the door to enabling cgo and external linking which will require ELFv2 support and userspace, eventually. Fixes #76244 Change-Id: I5ca15037cbe546f352e8693dcf14da51a308b8ca Reviewed-on: https://go-review.googlesource.com/c/go/+/734540 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-01-29cmd/link: put type:* at the start of the type descriptorsIan Lance Taylor
That used to happen naturally because the symbol had zero size. After CL 724261 we need to force it. Fixes #77372 Change-Id: Ia8eef989bc9cbad5459b60ff6535136e7e0c6cab Reviewed-on: https://go-review.googlesource.com/c/go/+/740400 Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-01-29cmd/link: remove AIX special case for first type descriptorIan Lance Taylor
It doesn't seem to be necessary, and removing it seems cleaner than adding an AIX case to the code in runtime.moduleTypelinks. Fixes #77365 Change-Id: I59fa56abf42e18017bd112481ea09d0cca47d105 Reviewed-on: https://go-review.googlesource.com/c/go/+/740220 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-01-29cmd/link: adjust symkind comparisons in XCOFF codeIan Lance Taylor
This XCOFF symkind comparison broke when STYPE moved in CL 723580. These comparisons are unmaintainable, but at least the new code is no worse than the old code. Change-Id: I1be9de6afdf1814aaadcd2105e6247a4b66b46fe Reviewed-on: https://go-review.googlesource.com/c/go/+/740200 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2026-01-29runtime, cmd/link: store type descriptor length, not endIan Lance Taylor
Storing the type descriptor length lets us save a relocation. It also avoids a problem for Darwin dynamic linking. For #6853 Fixes #77350 Change-Id: If5c94330fe10d75690325f3d0b0658060ef3eb2d Reviewed-on: https://go-review.googlesource.com/c/go/+/739681 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-01-27cmd/link, runtime: remove typelinksIan Lance Taylor
Instead of adding a typelinks section to a Go binary, mark the start and end of the typelinked type descriptors. The runtime can then step through the descriptors to find them all, rather than relying on the extra linker-generated offset list. The runtime steps through the type descriptors lazily, as many Go programs don't need the typelinks list at all. This reduces the size of cmd/go by 15K bytes, which isn't much but it's not nothing. A future CL will change the reflect package to use the type pointers directly rather than converting to offsets and then back to type pointers. For #6853 Change-Id: Id0af4ce81c5b1cea899fc92b6ff9d2db8ce4c267 Reviewed-on: https://go-review.googlesource.com/c/go/+/724261 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2026-01-27cmd/link: remove unused symbol kind SFUNCTABIan Lance Taylor
Change-Id: Ica7201dabe7f72b9470d8acbad043a34a20345a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/724121 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-01-27cmd/link: handle SRODATALRELRO in xcoffUpdateOuterSizeIan Lance Taylor
This is a followup to CL 723580. This fixes cgo builds on AIX. For #76038 Change-Id: Idea959615891f3f6e33932fae7a9043778db3366 Reviewed-on: https://go-review.googlesource.com/c/go/+/738920 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>