aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/arm64/obj.go
AgeCommit message (Collapse)Author
2025-10-07Revert "cmd/compile: redo arm64 LR/FP save and restore"Keith Randall
This reverts commit 719dfcf8a8478d70360bf3c34c0e920be7b32994. Reason for revert: Causing crashes. Change-Id: I0b8526dd03d82fa074ce4f97f1789eeac702b3eb Reviewed-on: https://go-review.googlesource.com/c/go/+/709755 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-10-06cmd/compile: redo arm64 LR/FP save and restoreKeith Randall
Instead of storing LR (the return address) at 0(SP) and the FP (parent's frame pointer) at -8(SP), store them at framesize-8(SP) and framesize-16(SP), respectively. We push and pop data onto the stack such that we're never accessing anything below SP. The prolog/epilog lengths are unchanged (3 insns for a typical prolog, 2 for a typical epilog). We use 8 bytes more per frame. Typical prologue: STP.W (FP, LR), -16(SP) MOVD SP, FP SUB $C, SP Typical epilogue: ADD $C, SP LDP.P 16(SP), (FP, LR) RET The previous word where we stored LR, at 0(SP), is now unused. We could repurpose that slot for storing a local variable. The new prolog and epilog instructions are recognized by libunwind, so pc-sampling tools like perf should now be accurate. (TODO: except maybe after the first RET instruction? Have to look into that.) Update #73753 (fixes, for arm64) Update #57302 (Quim thinks this will help on that issue) Change-Id: I4800036a9a9a08aaaf35d9f99de79a36cf37ebb8 Reviewed-on: https://go-review.googlesource.com/c/go/+/674615 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.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-01-31cmd/link: rename ELF struct fields to remove "elf" prefixIan Lance Taylor
While we're here rename setupplt to setupPLT. This is a pure naming change with no semantic change. Change-Id: Ib0312fb6568475b620dab7632438b4d25e4d9cc0 Reviewed-on: https://go-review.googlesource.com/c/go/+/463744 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2023-01-30cmd/link: refactor ELF hooks into ELFArch structIan Lance Taylor
This is a pure cleanup to bring the ELF hooks together. Change-Id: I01d5227c70f30e4a659dcd7904e7c247266e95b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/463981 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joel Sing <joel@sing.id.au>
2022-08-08cmd/link: detect glibc vs musl ldso at link timeRuss Cox
Doing the test at link time lets us distribute one Linux toolchain that works on both glibc-based and musl-based Linux systems. The old way built a toolchain that only ran on one or the other. Fixes #54197. Change-Id: Iaae8c274c78e1091eee828a720b49646be9bfffe Reviewed-on: https://go-review.googlesource.com/c/go/+/420774 Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
2021-04-29cmd/link: support trampoline insertion on ARM64Cherry Zhang
Compared to ARM32 or PPC64, ARM64 has larger range for direct jumps. But for very large programs it can still go over the limit. Add trampoline insertion for ARM64. Updates #40492. Change-Id: Id97301dbc35fb577ba3f8d5f3316a8424d4f53c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/314451 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-19cmd/link: add windows/arm64 supportRuss Cox
This CL is part of a stack adding windows/arm64 support (#36439), intended to land in the Go 1.17 cycle. Change-Id: I397c1d238bb18cbe78b3fca00910660cf1d66b8d Reviewed-on: https://go-review.googlesource.com/c/go/+/288822 Trust: Russ Cox <rsc@golang.org> Trust: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.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-10-14cmd/link: support internal linking on darwin/arm64Cherry Zhang
Add support of internal linking on darwin/arm64 (macOS). Still incomplete. Pure Go binaries work. Cgo doesn't. TLS is not set up when cgo is not used (as before) (so asynchronous preemption is not enabled). Internal linking is not enabled by default but can be requested via -ldflags=-linkmode=internal. Updates #38485. Change-Id: I1e0c81b6028edcb1ac26dcdafeb9bb3f788cf732 Reviewed-on: https://go-review.googlesource.com/c/go/+/261643 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-09-08cmd/link: enable DWARF combining on macOS ARM64Cherry Zhang
It appears the machoCalcStart function is meant to align the segment, but it doesn't. Replace it with an actual alignment calculation. Also, use the alignment from the configuration, instead of hardcode. With this fix we could enable DWARF combining on macOS ARM64. Change-Id: I19ec771b77d752b83a54c53b6ee65af78a31b8ae Reviewed-on: https://go-review.googlesource.com/c/go/+/253558 Reviewed-by: Than McIntosh <thanm@google.com>
2020-07-21[dev.link] cmd/link: stream external relocations on ARM64 and on DarwinCherry Zhang
Support streaming external relocations on ARM64. Support architecture-specific relocations. Also support streaming external relocations on Darwin. Do it in the same CL so ARM64's archreloc doesn't need to support both streaming and non-streaming. Change-Id: Ia7fee9957892f98c065022c69a51f47402f4d6e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/243644 Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-07-07[dev.link] cmd/link: emit Mach-O relocations in mmapCherry Zhang
Following CL 240399 and CL 240400, do the same for Mach-O. Linking cmd/compile with external linking, name old time/op new time/op delta Asmb2_GC 32.7ms ± 2% 13.5ms ± 6% -58.56% (p=0.008 n=5+5) name old alloc/op new alloc/op delta Asmb2_GC 16.5MB ± 0% 6.4MB ± 0% -61.15% (p=0.008 n=5+5) Change-Id: I0fd7019d8713d1940e5fbbce4ee8eebd926451a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/241178 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-07-06[dev.link] cmd/link: write ELF relocations in mmap on all architecturesCherry Zhang
In CL 240399 we changed to precompute the size for ELF relocation records and use mmap to write them, but we left architectures where elfreloc1 write non-fixed number of bytes. This CL handles those architectures. When a Go relocation will turn into multiple ELF relocations, in relocsym we account this difference and add it to the size calculation. So when emitting ELF relocations, we know the number of ELF relocations to be emitted. Change-Id: I6732ab674b442f4618405e5412a77f6e4a3315d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/241079 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-06-05[dev.link] all: merge branch 'master' into dev.linkCherry Zhang
Merge conflicts are mostly recently changed nm/objdump output format and its tests. Resolved easily (mostly just using the format on master branch). Change-Id: I99d8410a9a02947ecf027d9cae5762861562baf5
2020-06-04all: fix dead links to inferno-os bitbucket repositoryTobias Klauser
Generated using: perl -i -npe 's#inferno-os/src/default#inferno-os/src/master#' $(git grep -l "inferno-os/src/default" | grep -v vendor) Change-Id: I4b6443bd09a8ea4c8aaeb40a1c73520d1f7ca648 Reviewed-on: https://go-review.googlesource.com/c/go/+/235821 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com>
2020-05-26[dev.link] cmd/link: move asmb2 elf to generic handlingJeremy Faller
Change-Id: Ic3e90793f0ce49909c4f76df1272b25a1d61ebdf Reviewed-on: https://go-review.googlesource.com/c/go/+/234887 Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-21[dev.link] cmd/link: remove duplicate asmb codeJeremy Faller
Lots of the architecture specific code for asmb() is very simimar. As such, move to a common function. Change-Id: Id1fd50ee7bfa1bc9978e3f42ad08914b04cd677b Reviewed-on: https://go-review.googlesource.com/c/go/+/234683 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> 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-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-12[dev.link] cmd/link: expand architecture support for elf asmb2 pathThan McIntosh
Adds in support for remaining architectures to the linker's ELF asmb2 path, along with deleting most of the older sym.Symbol based code. Change-Id: I67c96525db72b7d6dd3187cf2b9f6faddc296291 Reviewed-on: https://go-review.googlesource.com/c/go/+/233362 Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-08[dev.link] cmd/link: delete old reloc passCherry Zhang
We use the new one everywhere now. Change-Id: Ic9b1314e71e4666500cbf1689bb93839e040682a Reviewed-on: https://go-review.googlesource.com/c/go/+/232982 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-05-05[dev.link] cmd/link: convert archreloc for arm64Than McIntosh
Switch to using loader interfaces for the arm64 version of archreloc. Change-Id: I12608a95d27622a7d578a2943a35fa8c89c11d52 Reviewed-on: https://go-review.googlesource.com/c/go/+/232201 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: delete old dodataCherry Zhang
Change-Id: I569bbee235630baad3c35ca0c6598b8bd059307a Reviewed-on: https://go-review.googlesource.com/c/go/+/230311 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-27[dev.link] cmd/link: support new dodata for elf/{arm,arm64}Than McIntosh
Add elf/ARM arch support for the new dodata() phase. Change-Id: Iadd772b01036c6c5be95bcc6017f6c05d45a24c0 Reviewed-on: https://go-review.googlesource.com/c/go/+/229868 Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-06[dev.link] cmd/link: begin converting gentext to loader APIsThan McIntosh
Begin the job of converting the linker's "gentext" phase over to use loader APIs. This patch includes most architectures except for s390x and PPC (these will be added in subsequent patches, since they require a couple of loader changes first). Change-Id: Ic7f55c207dcdbbba657330ef007a72ff7c837416 Reviewed-on: https://go-review.googlesource.com/c/go/+/227017 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-02-26cmd/link: default to internal linking for android/arm64Elias Naur
The bootstrapping process (make.bash) on all other platforms use internal linking. This change brings android/arm64 in line, fixing the scary warning on our self-hosted Corellium builders: warning: unable to find runtime/cgo.a The linkmode default is changed to internal for all Android programs, but in practice that won't matter outside our builders: using Go with Android apps requires buildmode=c-shared which uses linkmode external. Fixes #31343 Updates #31819 Change-Id: I3b3ada5ed69a7989e6d8e5960bbebf5e1c22aada Reviewed-on: https://go-review.googlesource.com/c/go/+/207299 Run-TryBot: Elias Naur <mail@eliasnaur.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-10-09all: remove the nacl port (part 2, amd64p32 + toolchain)Brad Fitzpatrick
This is part two if the nacl removal. Part 1 was CL 199499. This CL removes amd64p32 support, which might be useful in the future if we implement the x32 ABI. It also removes the nacl bits in the toolchain, and some remaining nacl bits. Updates #30439 Change-Id: I2475d5bb066d1b474e00e40d95b520e7c2e286e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/200077 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-05cmd/link/internal/arm64: add support for freebsd/arm64Tobias Klauser
Updates #24715 Change-Id: If5d9591a820f6e921e69e722d46bf91d2ae738cb Reviewed-on: https://go-review.googlesource.com/c/go/+/198543 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-26cmd/link: add support for openbsd/arm64Joel Sing
Updates #31656 Change-Id: Iff0b2c2b2ca95f8c246436e35a22b70efb8e61d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/174121 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-20all: add start of netbsd/arm64 supportMaya Rashish
This works well enough to run some code natively on arm64, but not well enough for more complicated code. I've been suggested to start a pull request anyway. Updates #30824 Change-Id: Ib4f63e0e8a9edfc862cf65b5f1b0fbf9a8a1628e GitHub-Last-Rev: b01b105e0446e349c8d9895d3ac6918fa0cdc48c GitHub-Pull-Request: golang/go#29398 Reviewed-on: https://go-review.googlesource.com/c/go/+/155739 Run-TryBot: Benny Siegert <bsiegert@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2019-04-19cmd/link: mmap output fileCherry Zhang
Use mmap for writing most of the output file content, specifically, the sections and segments. After layout, we already know the sizes and file offsets for the sections and segments. So we can just write the bytes by copying to a mmap'd backing store. The writing of the output file is split into two parts. The first part writes the sections and segments to the mmap'd region. The second part writes some extra content, for which we don't know the size, so we use direct file IO. This is in preparation for mmap'ing input files read-only. Change-Id: I9f3b4616a9f96bfd5c940d74c50aacd6d330f7d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/170738 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2019-03-01cmd/link: remove unused flag -D (FlagDataAddr)Alex Tokarev
FlagDataAddr is a vestige from git commit 0cafb9e (2008; no Gerrit CL number). It was never used but unfortunately setting it would cause a spurious warning: warning: -D<value> is ignored because of -R0x1000 yet if -R was unset e.g. -R=0, the linker would crash with a divide by zero runtime panic. Fixes #28921 Change-Id: Ia910399bc269337a9a860f3a26cd48fae6e62724 Reviewed-on: https://go-review.googlesource.com/c/151021 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-26cmd/link, cmd/go: enable DWARF on darwin/arm and darwin/arm64Cherry Zhang
Fixes #24883. Change-Id: Iff992ec3f2f31f4d82923d7cc806df4ee58e70b0 Reviewed-on: https://go-review.googlesource.com/108295 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Elias Naur <elias.naur@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-21cmd/link: move Headtype global to ctxtDavid Crawshaw
For #22095 Change-Id: Idcfdfe8a94db8626392658bb93429454238f648a Reviewed-on: https://go-review.googlesource.com/70835 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-04cmd/link: remove coutbuf global variableDavid Crawshaw
Begin passing coutbuf by as a parameter. To make the initial plumbing pass easier, it is also a field in the standard ctxt parameter. Consolidate the byte writing functions into the OutBuf object. The result is less architecture-dependent initialization. To avoid plumbing out everywhere we want to report an error, move handling of out file deletion to an AtExit function. For #22095 Change-Id: I0863695241562e0662ae3669666c7922b8c846f9 Reviewed-on: https://go-review.googlesource.com/67318 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-03cmd/link: remove SysArch global variableDavid Crawshaw
For #22095 Change-Id: I9d1f0d93f8fd701a24af826dc903eea2bc235de2 Reviewed-on: https://go-review.googlesource.com/67317 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-19cmd/internal/objabi: extract shared functionality from objMatthew Dempsky
Now only cmd/asm and cmd/compile depend on cmd/internal/obj. Changing the assembler backends no longer requires reinstalling cmd/link or cmd/addr2line. There's also now one canonical definition of the object file format in cmd/internal/objabi/doc.go, with a warning to update all three implementations. objabi is still something of a grab bag of unrelated code (e.g., flag and environment variable handling probably belong in a separate "tool" package), but this is still progress. Fixes #15165. Fixes #20026. Change-Id: Ic4b92fac7d0d35438e0d20c9579aad4085c5534c Reviewed-on: https://go-review.googlesource.com/40972 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-10-19cmd/link, cmd/internal/obj: stop exporting various namesIan Lance Taylor
Just happened to notice that these names (funcAlign and friends) are never referenced outside their package, so no need to export them. Change-Id: I4bbdaa4b0ef330c3c3ef50a2ca39593977a83545 Reviewed-on: https://go-review.googlesource.com/31496 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-12cmd/link: use HEADR to define FlagTextAddr (cosmetic change)David du Colombier
This cosmetic change defines ld.FlagTextAddr using ld.HEADR in the Plan 9 cases, like it is done for other operating systems. Change-Id: Ic929c1c437f25661058682cf3e159f0b16cdc538 Reviewed-on: https://go-review.googlesource.com/30912 Run-TryBot: David du Colombier <0intro@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-16cmd/link: skip arch-specific main functionDavid Crawshaw
Add some notes to main.go on what happens where. Change-Id: I4fb0b6c280e5f990ddc5d749267372b86870af6d Reviewed-on: https://go-review.googlesource.com/28970 TryBot-Result: Gobot Gobot <gobot@golang.org> Run-TryBot: David Crawshaw <crawshaw@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-16cmd/link: attempt to rationalize linkmode initDavid Crawshaw
This CL gives Linkmode a type, switches it to the standard flag handling mechanism, and deduplicates some logic. There is a semantic change in this CL. Previously if a link was invoked explicitly with -linkmode=internal, any condition that forced external linking would silently override this and use external linking. Instead it now fails with a reason why. I believe this is an improvement, but will change it back if there's disagreement. Fixes #12848 Change-Id: Ic80e341fff65ecfdd2b6fdd6079674cc7210fc5f Reviewed-on: https://go-review.googlesource.com/28971 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-16cmd/link: -buildmode=plugin support for linuxDavid Crawshaw
This CL contains several linker changes to support creating plugins. It collects the exported plugin symbols provided by the compiler and includes them in the moduledata. It treats a binary as being dynamically linked if it imports the plugin package. This lets the dynamic linker de-duplicate symbols. Change-Id: I099b6f38dda26306eba5c41dbe7862f5a5918d95 Reviewed-on: https://go-review.googlesource.com/27820 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-10cmd: fix format strings used with obj.HeadtypeJosh Bleecher Snyder
Found by vet. Introduced by CL 28853. Change-Id: I3199e0cbdb1c512ba29eb7e4d5c1c98963f5a954 Reviewed-on: https://go-review.googlesource.com/28957 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-09cmd/link, cmd/internal/obj: give Headtype a typeDavid Crawshaw
Separate out windows/windowsgui properly so we are not encoding some of the Headtype value in a separate headstring global. Remove one of the two copies of the variable from cmd/link. Remove duplicate string to headtype list. Change-Id: Ifa20fb9652a1dc95161e154aac11f15ad0f709d0 Reviewed-on: https://go-review.googlesource.com/28853 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-29all: fix obsolete inferno-os linksEmmanuel Odeke
Fixes #16911. Fix obsolete inferno-os links, since code.google.com shutdown. This CL points to the right files by replacing http://code.google.com/p/inferno-os/source/browse with https://bitbucket.org/inferno-os/inferno-os/src/default To implement the change I wrote and ran this script in the root: $ grep -Rn 'http://code.google.com/p/inferno-os/source/browse' * \ | cut -d":" -f1 | while read F;do perl -pi -e \ 's/http:\/\/code.google.com\/p\/inferno-os\/source\/browse/https:\/\/bitbucket.org\/inferno-os\/inferno-os\/src\/default/g' $F;done I excluded any cmd/vendor changes from the commit. Change-Id: Iaaf828ac8f6fc949019fd01832989d00b29b6749 Reviewed-on: https://go-review.googlesource.com/27994 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-26cmd/link: make DynlinkingGo a methodDavid Crawshaw
This will allow it to depend on whether plugin.Open is a symbol to be linked in. Change-Id: Ie9aa4216f2510fe8b10bc4665c8b19622b7122ea Reviewed-on: https://go-review.googlesource.com/27819 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-22cmd/link: turn some globals into flag pointer variablesMichael Matloob
This moves many of the flag globals into main and assigns them to their flag.String/Int64/... directly. Updates #16818 Change-Id: Ibbff44a273bbc5cb7228e43f147900ee8848517f Reviewed-on: https://go-review.googlesource.com/27473 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-21cmd/link: use standard library flag package where possibleMichael Matloob
The obj library's flag functions are (mostly) light wrappers around the standard library flag package. Use the flag package directly where possible. Most uses of the 'count'-type flags (except for -v) only check against 0, so they can safely be replaced by bools. Only -v and the flagfns haven't been replaced. Debug has been turned into a slice of bools rather than ints. There was a copy of the -v verbosity in ctxt.Debugvlog, so don't use Debug['v'] and just use ctxt.Debugvlog. Updates #16818 Change-Id: Icf6473a4823c9d35513bbd0c34ea02d5676d782a Reviewed-on: https://go-review.googlesource.com/27471 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-21cmd/link/internal: remove global Ctxt variableMichael Matloob
This change threads the *ld.Link Ctxt variable through code in arch-specific packages. This removes all remaining uses of Ctxt, so remove the global variable too. This CL continues the work in golang.org/cl/27408 Updates #16818 Change-Id: I5f4536847a1825fd0b944824e8ae4e122ec0fb78 Reviewed-on: https://go-review.googlesource.com/27459 Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>