aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/ld/xcoff.go
AgeCommit message (Collapse)Author
2026-02-03all: prealloc slice with possible minimum capabilitiesShulhan
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-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>
2026-01-22cmd/link: put type descriptors in .go.type sectionIan Lance Taylor
This change rewrites and simplifies the relro handling. We eliminate the separate relro SymKind values and the complex shifting of symbol kinds. Instead, we put the possible relro data into their own sections, and make those sections relro when appropriate. We put type descriptors and their associated data into a new .go.type section. As part of this we change the runtime.etypes symbol to be the end of the new section, rather than the end of rodata as it was before. We put function descriptors into a new .go.func section. Ordinary rodata relro stays in the .data.rel.ro section. We stop making the typelink section relro, as it only contains offsets and never has dynamic relocations. We drop the typerel:* and go:funcdescrel symbols. For #76038 Change-Id: I7aab7cfad3f2623ff06c09a70b756fe1e43f4169 Reviewed-on: https://go-review.googlesource.com/c/go/+/723580 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> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-12-08cmd/link: fix AIX builds after recent linker changesIan Lance Taylor
This updates XCOFF-specific code for the recent addition of funcdata to pclntab. Because XCOFF puts separate symbols into separate csects, each with their own alignment, it's important to tell the external linker the expected alignment of each part of pclntab. Otherwise the offsets within pclntab may change as the external linker aligns symbols. This CL sets the correct alignment for each pclntab child symbol, and sets pclntab's alignment to the max of that of its children. Tested on the GCC compile farm. Fixes #76486 Change-Id: I77d8a90c4b4b79d80ca11ede8d9a2aa9cc89f53f Reviewed-on: https://go-review.googlesource.com/c/go/+/725603 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: David Chase <drchase@google.com>
2025-11-26cmd/link: put moduledata in its own .go.module sectionIan Lance Taylor
There is a test for this in CL 721480 later in this series. For #76038 Change-Id: Ib7ed1f0b0aed2d929ca0f135b54d6b62112cae30 Reviewed-on: https://go-review.googlesource.com/c/go/+/720660 TryBot-Bypass: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
2025-11-11std,cmd: go fix -any std cmdAlan Donovan
This change mechanically replaces all occurrences of interface{} by 'any' (where deemed safe by the 'any' modernizer) throughout std and cmd, minus their vendor trees. Since this fix is relatively numerous, it gets its own CL. Also, 'go generate go/types'. Change-Id: I14a6b52856c3291c1d27935409bca8d5fd4242a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/719702 Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Alan Donovan <adonovan@google.com>
2025-11-04cmd/link: add and use new SymKind SFirstUnallocatedIan Lance Taylor
The linker sources in several places used SXREF to mark the first SymKind which is not allocated in memory. This is cryptic. Instead use SFirstUnallocated, following the example of the existing SFirstWritable. Change-Id: If326ad63027402699094bcc49ef860db3772f82a Reviewed-on: https://go-review.googlesource.com/c/go/+/715623 Reviewed-by: Than McIntosh <thanm@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-10-21all: eliminate unnecessary type conversionsJes Cok
Found by github.com/mdempsky/unconvert Change-Id: I88ce10390a49ba768a4deaa0df9057c93c1164de GitHub-Last-Rev: 3b0f7e8f74f58340637f33287c238765856b2483 GitHub-Pull-Request: golang/go#75974 Reviewed-on: https://go-review.googlesource.com/c/go/+/712940 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com>
2025-09-29cmd/link: use a .def file to mark exported symbols on Windowsqmuntal
Binutils defaults to exporting all symbols when building a Windows DLL. To avoid that we were marking symbols with __declspec(dllexport) in the cgo-generated headers, which instructs ld to export only those symbols. However, that approach makes the headers hard to reuse when importing the resulting DLL into other projects, as imported symbols should be marked with __declspec(dllimport). A better approach is to generate a .def file listing the symbols to export, which gets the same effect without having to modify the headers. Updates #30674 Fixes #56994 Change-Id: I22bd0aa079e2be4ae43b13d893f6b804eaeddabf Reviewed-on: https://go-review.googlesource.com/c/go/+/705776 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Than McIntosh <thanm@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-07cmd/internal/objabi, cmd/link: introduce SymKind helper methodsRuss Cox
These will be necessary when we start using the new FIPS symbols. Split into a separate CL so that these refactoring changes can be tested separate from any FIPS-specific changes. Passes golang.org/x/tools/cmd/toolstash/buildall. Change-Id: I73e5873fcb677f1f572f0668b4dc6f3951d822bc Reviewed-on: https://go-review.googlesource.com/c/go/+/625996 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Russ Cox <rsc@golang.org>
2024-11-07cmd/link: remove dummy argument from ld.ErrorfRuss Cox
As the comment notes, all calls to Errorf now pass nil, so remove that argument entirely. There is a TODO to remove uses of Errorf entirely, but that seems wrong: sometimes there is no symbol on which to report the error, and in that situation, Errorf is appropriate. So clarify that in the docs. Change-Id: I92b3b6e8e3f61ba8356ace8cd09573d0b55d7869 Reviewed-on: https://go-review.googlesource.com/c/go/+/625617 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-12-01cmd/link: update flag docCherry Mui
Update the go doc for linker flags. Remove flags that no longer exist. Also remove flags that are intended for debugging the linker from user docs. Add -aslr to the doc. The -n flag does nothing except print a nearly useless message on XCOFF linking. Deprecate it. Fixes #64476. Change-Id: I518c9c6cc009eae50b7c11308348524ad6a62b69 Reviewed-on: https://go-review.googlesource.com/c/go/+/546615 Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-14cmd/link: clean up some unnecessary castsCherry Mui
In CL 527822, the type of FlagRound is changed to *int64, so casts to int64 are no longer necessary. Remove them. Change-Id: I68a89f6e51e0ae3813cb79959b8062ca6bea4980 Reviewed-on: https://go-review.googlesource.com/c/go/+/528575 Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-13cmd/link: round up default start address to alignmentCherry Mui
If the -R flag (the segment alignment) is specified but the -T flag (start address) is not, currently the default start address may be under-aligned, and some math in the linker may be broken. Round up the start address to align it. Fixes #62064. Change-Id: I3b98c9d0cf7d3cd944b9436a36808899d2e52572 Reviewed-on: https://go-review.googlesource.com/c/go/+/527822 Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-04-04all: fix misuses of "a" vs "an"cui fliter
Fixes the misuse of "a" vs "an", according to English grammatical expectations and using https://www.a-or-an.com/ Change-Id: I53ac724070e3ff3d33c304483fe72c023c7cda47 Reviewed-on: https://go-review.googlesource.com/c/go/+/480536 Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-02-02cmd/link: remove special cases for relocations in .go.buildinfoRuss Cox
.go.buildinfo has no relocations anymore, as of Go 1.18. Change-Id: I98369c6a0ef07ada770eaa12f6f56c210e812abc Reviewed-on: https://go-review.googlesource.com/c/go/+/464436 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-11-18all: add missing periods in commentscui fliter
Change-Id: I69065f8adf101fdb28682c55997f503013a50e29 Reviewed-on: https://go-review.googlesource.com/c/go/+/449757 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joedian Reid <joedian@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-27cmd/link: fix coverage counter issue on AIXThan McIntosh
Update the linker's XCOFF writer to handle coverage counter sections properly; they need to be treated as bss, not data. Fixes a problem with the aix-ppc64 builder introduced in CL 401235), e.g. "runtime.covctrs: A symbol with type XTY_SD must be in a .text or .data section". Updates #51430. Change-Id: I3fc385a37e2549c46cc7cc3b4718af989a36752a Reviewed-on: https://go-review.googlesource.com/c/go/+/435335 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: David Chase <drchase@google.com>
2022-09-20all: replace package ioutil with os and io in srcAndy Pan
For #45557 Change-Id: I56824135d86452603dd4ed4bab0e24c201bb0683 Reviewed-on: https://go-review.googlesource.com/c/go/+/426257 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-08-09all: use ":" for compiler generated symbolsCuong Manh Le
As it can't appear in user package paths. There is a hack for handling "go:buildid" and "type:*" on windows/386. Previously, windows/386 requires underscore prefix on external symbols, but that's only applied for SHOSTOBJ/SUNDEFEXT or cgo export symbols. "go.buildid" is STEXT, "type.*" is STYPE, thus they are not prefixed with underscore. In external linking mode, the external linker can't resolve them as external symbols. But we are lucky that they have "." in their name, so the external linker see them as Forwarder RVA exports. See: - https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#export-address-table - https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/pe-dll.c;h=e7b82ba6ffadf74dc1b9ee71dc13d48336941e51;hb=HEAD#l972) This CL changes "." to ":" in symbols name, so theses symbols can not be found by external linker anymore. So a hacky way is adding the underscore prefix for these 2 symbols. I don't have enough knowledge to verify whether adding the underscore for all STEXT/STYPE symbols are fine, even if it could be, that would be done in future CL. Fixes #37762 Change-Id: I92eaaf24c0820926a36e0530fdb07b07af1fcc35 Reviewed-on: https://go-review.googlesource.com/c/go/+/317917 Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-20cmd/compile, cmd/link: use libFuzzer 8-bit instead of extra countersKhaled Yakdan
By using libFuzzer’s 8-bit counters instead of extra counters, the coverage instrumentation in libFuzzer mode is improved in three ways: 1- 8-bit counters are supported on all platforms, including macOS and Windows, with all relevant versions of libFuzzer, whereas extra counters are a Linux-only feature that only recently received support on Windows. 2- Newly covered blocks are now properly reported as new coverage by libFuzzer, not only as new features. 3- The NeverZero strategy is used to ensure that coverage counters never become 0 again after having been positive once. This resolves issues encountered when fuzzing loops with iteration counts that are multiples of 256 (e.g., larger powers of two). Change-Id: I9021210d7fbffd07c891ad08750402ee91cb3df5 GitHub-Last-Rev: 9057e4b21d146ce9ffb3993982bfb84b96705989 GitHub-Pull-Request: golang/go#51318 Reviewed-on: https://go-review.googlesource.com/c/go/+/387334 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2022-04-11all: gofmt main repoRuss Cox
[This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-20cmd/link: exit early when -d is used on libc platformsCherry Mui
On platforms where we use libc for syscalls, we dynamically link with libc and therefore dynamic linking cannot be disabled. Exit early when -d is specified. Update #42459. Change-Id: I05abfe111df723b5ee512ceafef734e3804dd0a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/365658 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2021-10-05cmd/link: mangle function name with ABI on XCOFFCherry Mui
This is like CL 304432 and CL 307229, for XCOFF. With this, GOEXPERIMENT=regabi works on AIX/PPC64. Change-Id: I8cf00681df5c93f397913febd78f38099d91e7c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/353972 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2021-09-22cmd/link: remove ABI aliasesCherry Mui
It is now gone. Change-Id: I59f68b324af706476695de2f291dd3aa5734e192 Reviewed-on: https://go-review.googlesource.com/c/go/+/351332 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-27cmd/link: enforce larger alignment on split ppc64 text sectionsPaul E. Murphy
When laying out, we lazily increase the alignment for text sections as symbols are found requiring more. This works if the start of the virtual address (VA) for the section is greater than or equal to the alignment required by any symbols placed in this section. The minimum alignment of the section is only known after all symbols are placed. The starting VA of this section is adjusted upwards in ld.(*Link).address to meet the requested alignment. This is a problem if the starting VA of the text section is not already aligned. This can happen when the final symbol placed into the previous section results in an insufficiently aligned start VA of the next text section. To workaround this, additional text sections are split, and both the starting VA, and alignment of the section are aligned up to match the known worst case alignment. 64B is chosen as the worst case alignment for all ppc64 targets, as it will respect PCALIGN and eventually prefixed instructions which will be introduced in the future. Likewise, the xcoff size calculations need to be improved to handle padding bytes when function symbols have been aligned. This is done by tracking the largest valid VA offset encountered when placing symbols. Change-Id: Iefef09a1ee7c963fb8dfce2288a084a95cb77fca Reviewed-on: https://go-review.googlesource.com/c/go/+/307431 Run-TryBot: Paul Murphy <murp@ibm.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-04-16cmd/link: fix file-local checks in xcoffAustin Clements
The xcoff writer has several "ldr.SymVersion(s) != 0" checks. The intent of these is to check for file-local (or static) symbols. Prior to the introduction of symbol ABIs, this was indeed equivalent since only file-local symbols has non-zero versions, but ABIs also use the symbol version space. This still happened to work until much more recently because we were only ever cgo-exporting version 0 symbols, but CL 309341 changed this, causing these checks to fail on symbols that were okay to export. Replace these checks with ldr.IsFileLocal(s). This should fix the AIX builder. (Originally based on CL 309772.) Fixes #45553. Updates #40724. Change-Id: I0a3a7f621ad8f9fe078d34e667286275257691ea Reviewed-on: https://go-review.googlesource.com/c/go/+/310729 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-16cmd/link: handle large relocation addend on darwin/arm64Cherry Zhang
Mach-O relocation addend is signed 24-bit. When external linking, if the addend is larger, we cannot put it directly into a Mach-O relocation. This CL handles large addend by creating "label" symbols at sym+0x800000, sym+(0x800000*2), etc., and emitting Mach-O relocations that target the label symbols with a smaller addend. The label symbols are generated late (similar to what we do for RISC-V64). One complexity comes from handling of carrier symbols, which does not track its size or its inner symbols. But relocations can target them. We track them in a side table (similar to what we do for XCOFF, xcoffUpdateOuterSize). Fixes #42738. Change-Id: I8c53ab2397f8b88870d26f00e9026285e5ff5584 Reviewed-on: https://go-review.googlesource.com/c/go/+/278332 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-08-03[dev.link] cmd/link: fix pclntab symbol handling on AIXCherry Zhang
On AIX, container symbols are handled in a weird way (unlike other platforms): the outer symbol needs to have size (but still no data), and the inner symbols must not be in the symbol table (otherwise it overlaps with the outer symbol, which the system linker doesn't like). As of CL 241598, pclntab becomes a container symbol. We need to follow the rule above for AIX. Fix AIX build. Change-Id: Ie2515a4cabbd8cf3f6d3868643a28f64ca3365a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/246479 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-08-03[dev.link] cmd/compile, cmd/link: generate itablink at link timeCherry Zhang
Currently, at compile time, for each itab symbol, we create an "itablink" symbol which holds solely the address of the itab symbol. At link time, all the itablink symbols are grouped together to form the itablinks slice. This CL removes the itablink symbols, and directly generate the itablinks slice in the linker. This removes a number of symbols, which are dupOK and generally have long names. And also removes a special handling of itablink symbols in the deadcode pass which iterates through all symbols. Change-Id: I475c3c8899e9fbeec9abc7647b1e4a69aa5c3c5a Reviewed-on: https://go-review.googlesource.com/c/go/+/245901 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-30[dev.link] cmd/link: remove "2", another roundCherry Zhang
Rename Reloc2 to Reloc, At2 to At, Aux2 to Aux. Change-Id: Ic98d83c080e8cd80fbe1837c8f0aa134033508ce Reviewed-on: https://go-review.googlesource.com/c/go/+/245578 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-30[dev.link] cmd/link: remove loader.RelocCherry Zhang
We have Reloc and Reloc2. Reloc2 is the better approach and most code uses Reloc2. There are still uses of Reloc. This CL migrates them to Reloc2, and removes Reloc. Change-Id: Id5f6a6019e1e044add682d05e70ebb1548ec58d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/245577 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-30[dev.link] cmd/link: refactor ExtReloc data structuresCherry Zhang
We used to generate all external relocations in memory, then emit the relocation records at a later pass. The data structures were chosen so that it takes as little memory as possible. Now we just stream out external relocations, and ExtReloc is just a local variable. Change the data structure to avoid repeated read of some fields. Also get rid of ExtRelocView, as it is no longer necessary. Change-Id: I40209bbe4387af231b29788125c3b4ebb0ff4a33 Reviewed-on: https://go-review.googlesource.com/c/go/+/245479 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-23[dev.link] cmd/link: stream external relocations on PPC64Cherry Zhang
Both ELF and Xcoff. Now we support streaming on all platforms. Later CLs will clean up the old code. Change-Id: Ieeef7844a3e229429983a8bc108d7f3fabf618e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/244358 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-06-24[dev.link] cmd/link: fix data race on AIXCherry Zhang
On AIX, in relocsym we call Xcoffadddynrel, which adds a relocation record to a global array. relocsym already runs in parallel. In the past we only parallelize over segments, and we call Xcoffadddynrel only for symbols in data segment, so it is effectively called sequentially. In CL 239197 we started to do more fine-grained parallelism, so we need to make sure it is safe to call Xcoffadddynrel in parallel. Fix AIX build. Change-Id: I3128193995a5a99d9fa04c8e728e590f17298da3 Reviewed-on: https://go-review.googlesource.com/c/go/+/239561 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-06-17[dev.link] cmd/link: remove implicit reachability setting from SymbolBuilderThan McIntosh
The loader's SymbolBuilder Add*/Set* methods include a call to mark the underlying symbol as reachable (as a convenience, so that callers would not have to set it explicitly). This code was carried over from the corresponding sym.Symbol methods; back in the sym.Symbol world unreachable symbols were never removed from the AllSyms slice, hence setting and checking reachability was a good deal more important. With the advent of the loader and the new deadcode implementation, there is less of a need for this sort of fallback, and in addition the implicit attr setting introduces data races in the the loader if there are SymbolBuilder Add*/Set* method calls in parallel threads, as well as adding overhead to the methods. This patch gets rid of the implicit reachability setting, and instead marks reachability in CreateSymForUpdate, as well as adding a few explicit SetAttrReachable calls where needed. Change-Id: I029a0c5a4a24237826a7831f9cbe5180d44cbc40 Reviewed-on: https://go-review.googlesource.com/c/go/+/237678 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-05-29[dev.link] cmd/link: simplify asmb2Jeremy Faller
Move lots of the binary-file format specific pieces into their appropriate places. Similarly rescope some variables to just ld. Change-Id: I74bc6d8aba58f5ac86e6579be1fcb356c4636825 Reviewed-on: https://go-review.googlesource.com/c/go/+/235278 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-05-26[dev.link] cmd/link: change asmb2 api and rescope some functionsJeremy Faller
Change-Id: I49916b4740316a7042566e389759b70d7b1fa037 Reviewed-on: https://go-review.googlesource.com/c/go/+/234895 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-18[dev.link] cmd/link: remove "2" from namesCherry Zhang
Change-Id: I203caaf9cbe7136cf2060de7dc91c28f6ced1ee2 Reviewed-on: https://go-review.googlesource.com/c/go/+/234038 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-05-14[dev.link] cmd/link: move xcoff to loader represenatationJeremy Faller
Change-Id: I5b260493ffd7945f665c466e892be18d81e7940a Reviewed-on: https://go-review.googlesource.com/c/go/+/233340 Run-TryBot: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-13[dev.link] cmd/link: rename adddynrel2 back to adddynrelThan McIntosh
Minor renaming cleanup to get rid of a couple of old sym.Symbol adddynrel helpers and rename the current crop of adddynrel2 methods/functions back to adddynrel. Change-Id: I67e76decff84d603ef765f3b6a0cd78c7f3743ec Reviewed-on: https://go-review.googlesource.com/c/go/+/233523 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-08[dev.link] cmd/link: convert ppc64 archreloc over to LoaderJeremy Faller
Change-Id: I68945a8284fb3dd9ceb5a9cd774b5b4b91e63ce0 Reviewed-on: https://go-review.googlesource.com/c/go/+/230917 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-30[dev.link] cmd/link: pass reloc by value to Adddynrel2Cherry Zhang
Adddynrel2 is a function pointer. In dynrelocsym we pass &r to it, which will cause r to escape. Pass it by value instead. Linking cmd/compile, name old alloc/op new alloc/op delta Dodata_GC 15.8MB ± 0% 5.9MB ± 0% -62.55% (p=0.008 n=5+5) Change-Id: Ib86005d1026ebaca57777b27ead037e613585f44 Reviewed-on: https://go-review.googlesource.com/c/go/+/231045 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-28[dev.link] cmd/link: remove Gotype and File fields from sym.SymbolThan McIntosh
Remove the 'Gotype' field from sym.Symbol, as it is now no longer used. Store the loader.Sym for a symbol as a field in sym.Symbol ("SymIdx"). Then remove sym.Symbol 'File' field, and replace the field accesses in question with calls into the loader instead. Change-Id: I01c5504425006b8d3fe77fac2b69a86e198c7a5a Reviewed-on: https://go-review.googlesource.com/c/go/+/230304 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-28[dev.link] cmd/link: tweak genasmsym to eliminate Gotype refThan McIntosh
None of the users of genasmsym are doing anything with the Gotype field of sym.Symbol, so remove that param from the callback function. Change-Id: Ie902c4cdbcc6b68d353daf5ce21a99012161a946 Reviewed-on: https://go-review.googlesource.com/c/go/+/230545 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-27[dev.link] cmd/link: accept more types in XcoffadddynrelCherry Zhang
In dodata we overwrite symbol types to SDATA. Now we'll stop doing that, so accept more symbol types here. This is basically a list of all writeable types handled in dodata that could appear in XCOFF. Change-Id: Iee35369162f5acd59806a3f0e6c8d3682620067e Reviewed-on: https://go-review.googlesource.com/c/go/+/230310 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-27[dev.link] cmd/link: support new dodata for PPC64Than McIntosh
Add linux/{ppc64,ppc64le} and aix/ppc64 arch support for the new dodata() phase. This completes the picture in terms of architecture support for the new dodata(), but to be safe this patch leaves the command line flag in place there are problems on the builders (especially given that we have a dead aix-ppc64 builder). Change-Id: I78da615c3b540d8925ed7b3226e199280eb7451d Reviewed-on: https://go-review.googlesource.com/c/go/+/229983 Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-27[dev.link] cmd/link: remove ctxt.Syms.AllsymCherry Zhang
Replace remaining uses with loader.Syms. Reduces some memory usage. Change-Id: I6f295b42b8cd734c6c18f08c61a5473506675075 Reviewed-on: https://go-review.googlesource.com/c/go/+/229992 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>