aboutsummaryrefslogtreecommitdiff
path: root/src/liblink/asm5.c
AgeCommit message (Collapse)Author
2015-02-26liblink: delete unused codeRuss Cox
Liblink is still needed for the linker (for a bit longer) but mostly not. Delete the unused parts. Change-Id: Ie63a7c1520dee52b17425b384943cd16262d36e3 Reviewed-on: https://go-review.googlesource.com/6110 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-11cmd/gc: factor newly-portable code into gc directoryRuss Cox
This isn't everything, but it's a start. Still producing bit-identical compiler output. The semantics of the old back ends is preserved, even when they are probably buggy. There are some TODOs in gc/gsubr.c to remove special cases to preserve bugs in 5g and 8g. Change-Id: I28ae295fbfc94ef9df43e13ab96bd6fc2f194bc4 Reviewed-on: https://go-review.googlesource.com/3802 Reviewed-by: Austin Clements <austin@google.com>
2015-02-09liblink, runtime: move all references to runtime.tlsg to tls_arm.sShenghou Ma
CL 2118 makes the assumption that all references to runtime.tlsg should be accompanied by a declaration of runtime.tlsg if its type should be a normal variable, instead of a placeholder for TLS relocation. Because if runtime.tlsg is not declared by the runtime package, the type of runtime.tlsg will be zero, so fix the check in liblink to look for 0 instead of STLSBSS (the type will be initialized by cmd/ld, but cmd/ld doesn't run during assembly). Change-Id: I691ac5c3faea902f8b9a0b963e781b22e7b269a7 Reviewed-on: https://go-review.googlesource.com/4030 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-02-06liblink, cmd/ld, runtime: set the type of runtime.tlsg in runtimeShenghou Ma
In the old code, liblink, cmd/ld and runtime all have code determine whether runtime.tlsg is an actual variable or a placeholder for TLS relocation. This change consolidate them into one: the runtime/tls_arm.s will ultimately determine the type of that variable. Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237e43 Reviewed-on: https://go-review.googlesource.com/2118 Reviewed-by: David Crawshaw <crawshaw@golang.org> Reviewed-by: Dave Cheney <dave@cheney.net>
2015-02-05Revert "liblink, cmd/5a: fix reglist parsing/printing after changing REG_R0 ↵Russ Cox
to 32" This reverts commit da4abda2a1718c74b39134764ae6f694041a25e4. Change-Id: Ifd09b3dae0af0c7cef5fbbc332c63e78dc90d6b1 Reviewed-on: https://go-review.googlesource.com/3960 Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-05liblink, cmd/5a: fix reglist parsing/printing after changing REG_R0 to 32Shenghou Ma
Fixes #9759. Change-Id: I263f1251b9401371231374551c4f71c70cb6e359 Signed-off-by: Shenghou Ma <minux@golang.org> Reviewed-on: https://go-review.googlesource.com/3931 Reviewed-by: Dave Cheney <dave@cheney.net>
2015-02-04liblink: require use of TYPE_ADDR, not TYPE_CONSTRuss Cox
Add Addr-checking for all Progs on input to liblink, in liblink/pass.c, including requiring use of TYPE_ADDR, not TYPE_CONST. Update compilers and assemblers to satisfy checks. Change-Id: Idac36b9f6805f0451cb541d2338992ca5eaf3963 Reviewed-on: https://go-review.googlesource.com/3801 Reviewed-by: Austin Clements <austin@google.com>
2015-02-03liblink: define fixed A-numbers for common instructionsRuss Cox
This makes names like ANOP, ATEXT, AGLOBL, ACALL, AJMP, ARET available for use by architecture-independent processing passes. On arm and ppc64, the alternate names are now aliases for the official ones (ABL for ACALL, AB or ABR for AJMP, ARETURN for ARET). Change-Id: Id027771243795af2b3745199c645b6e1bedd7d18 Reviewed-on: https://go-review.googlesource.com/3577 Reviewed-by: Aram Hăvărneanu <aram@mgk.ro> Reviewed-by: Austin Clements <austin@google.com>
2015-02-03liblink: the zero Prog is now valid and ready for useRuss Cox
Use AXXX instead of AGOK (neither is a valid instruction but AXXX is zero) for the initial setting of Prog.as, and now there are no non-zero default field settings. Remove the arch-specific zprog/zprg in favor of a single global zprog. Remove the arch-specific prg constructor in favor of emallocz(sizeof(Prog)). Change-Id: Ia73078726768333d7cdba296f548170c1bea9498 Reviewed-on: https://go-review.googlesource.com/3575 Reviewed-by: Aram Hăvărneanu <aram@mgk.ro> Reviewed-by: Austin Clements <austin@google.com>
2015-02-03liblink: renumber ARM conditions to make C_SCOND_NONE == 0Russ Cox
A step toward making the zero Prog useful. Change-Id: I427b98b1ce9bd8f093da825aa4bb83244fc01903 Reviewed-on: https://go-review.googlesource.com/3573 Reviewed-by: Dave Cheney <dave@cheney.net> Reviewed-by: Austin Clements <austin@google.com>
2015-02-03liblink: place TEXT/GLOBL flags in p->from3 alwaysRuss Cox
Before, amd64 and 386 stored the flags in p->from.scale and arm and ppc64 stored the flags in p->reg. Both caused special cases in printing and in handling of the addresses. To avoid possible conflicts with the real meaning of p->from and to avoid storing a non-register value in a reg field, use from3 to hold a TYPE_CONST value giving the flags. There is still a special case for printing, because the flags are specified without a $, and normally a TYPE_CONST prints with a $. But that's much less special than what came before. This allows us to remove the textflag and settextflag methods from LinkArch. They are no longer architecture-specific. Change-Id: I931da8e1ecd92e127cd9aa44ef5a73c42e730110 Reviewed-on: https://go-review.googlesource.com/3572 Reviewed-by: Austin Clements <austin@google.com>
2015-02-03liblink: use same TEXT $frame-arg encoding for all architecturesRuss Cox
Change-Id: I3417a8c5ddd7f405939edc9fdef086e4741495a1 Reviewed-on: https://go-review.googlesource.com/3571 Reviewed-by: Austin Clements <austin@google.com>
2015-01-30cmd/5a, cmd/5g, cmd/5l, liblink: update for portable Prog, AddrRuss Cox
Change-Id: I06762d4fb3bb2616087339b6ae1eb5267a39c46a Reviewed-on: https://go-review.googlesource.com/3516 Reviewed-by: Austin Clements <austin@google.com>
2015-01-14liblink: adjustments for c2go conversionRuss Cox
Mostly this is using uint32 instead of int32 for unsigned values like instruction encodings or float32 bit representations, removal of ternary operations, and removal of #defines. Delete sched9.c, because it is not compiled (it is still in the history if we ever need it). Change-Id: I68579cfea679438a27a80416727a9af932b088ae Reviewed-on: https://go-review.googlesource.com/2658 Reviewed-by: Austin Clements <austin@google.com>
2014-09-08build: adjustments for move from src/pkg to srcRuss Cox
This CL adjusts code referring to src/pkg to refer to src. Immediately after submitting this CL, I will submit a change doing 'hg mv src/pkg/* src'. That change will be too large to review with Rietveld but will contain only the 'hg mv'. This CL will break the build. The followup 'hg mv' will fix it. For more about the move, see golang.org/s/go14nopkg. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/134570043
2014-09-06liblink: fix arm build errorsRuss Cox
This was supposed to be in CL 135490044 but got lost in a transfer from machine to machine. TBR=khr R=khr CC=golang-codereviews https://golang.org/cl/135560043
2014-08-06liblink, cmd/dist, cmd/5l: introduce %^ and move C_* constants.Shenghou Ma
The helps certain diagnostics and also removed duplicated enums as a side effect. LGTM=dave, rsc R=rsc, dave CC=golang-codereviews https://golang.org/cl/115060044
2014-07-23liblink: more precise literal word comparison on armRuss Cox
There are fields in the Addr that do not matter for the purpose of deciding that the same word is already in the current literal pool. Copy only the fields that do matter. This came up when comparing against the Go version because the way it is invoked doesn't copy a few fields (like node) that are never directly used by liblink itself. Also remove a stray print that is not well-defined in the new liblink. (Cannot use %D outside of %P, because %D needs the outer Prog*.) LGTM=minux R=minux CC=golang-codereviews https://golang.org/cl/119000043
2014-07-21liblink: remove some gotos + other fixesRuss Cox
Rewrite gotos that violate Go's stricter rules. Use uchar* instead of char* in a few places that aren't strings. Remove dead opcross code from asm5.c. Declare regstr (in both list6 and list8) static. LGTM=minux, dave R=minux, dave CC=golang-codereviews https://golang.org/cl/113230043
2014-07-11liblink: fix warnings on Plan 9David du Colombier
warning: /usr/go/src/liblink/asm5.c:720 set and not used: m warning: /usr/go/src/liblink/asm5.c:807 set and not used: c LGTM=minux R=minux CC=golang-codereviews https://golang.org/cl/108570043
2014-07-10cmd/5c, cmd/5g, cmd/5l, liblink: nacl/arm supportShenghou Ma
LGTM=dave, rsc R=rsc, iant, dave CC=golang-codereviews https://golang.org/cl/108360043
2014-07-02build: annotations and modifications for c2goRuss Cox
The main changes fall into a few patterns: 1. Replace #define with enum. 2. Add /*c2go */ comment giving effect of #define. This is necessary for function-like #defines and non-enum-able #defined constants. (Not all compilers handle negative or large enums.) 3. Add extra braces in struct initializer. (c2go does not implement the full rules.) This is enough to let c2go typecheck the source tree. There may be more changes once it is doing other semantic analyses. LGTM=minux, iant R=minux, dave, iant CC=golang-codereviews https://golang.org/cl/106860045
2014-06-26all: remove 'extern register M *m' from runtimeRuss Cox
The runtime has historically held two dedicated values g (current goroutine) and m (current thread) in 'extern register' slots (TLS on x86, real registers backed by TLS on ARM). This CL removes the extern register m; code now uses g->m. On ARM, this frees up the register that formerly held m (R9). This is important for NaCl, because NaCl ARM code cannot use R9 at all. The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected: BenchmarkBinaryTree17 5491374955 5471024381 -0.37% BenchmarkFannkuch11 4357101311 4275174828 -1.88% BenchmarkGobDecode 11029957 11364184 +3.03% BenchmarkGobEncode 6852205 6784822 -0.98% BenchmarkGzip 650795967 650152275 -0.10% BenchmarkGunzip 140962363 141041670 +0.06% BenchmarkHTTPClientServer 71581 73081 +2.10% BenchmarkJSONEncode 31928079 31913356 -0.05% BenchmarkJSONDecode 117470065 113689916 -3.22% BenchmarkMandelbrot200 6008923 5998712 -0.17% BenchmarkGoParse 6310917 6327487 +0.26% BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17% BenchmarkRegexpMatchHard_1K 168977 169244 +0.16% BenchmarkRevcomp 935294971 914060918 -2.27% BenchmarkTemplate 145917123 148186096 +1.55% Minux previous reported larger variations, but these were caused by run-to-run noise, not repeatable slowdowns. Actual code changes by Minux. I only did the docs and the benchmarking. LGTM=dvyukov, iant, minux R=minux, josharian, iant, dave, bradfitz, dvyukov CC=golang-codereviews https://golang.org/cl/109050043
2014-05-07runtime: use duff zero and copy to initialize memoryKeith Randall
benchmark old ns/op new ns/op delta BenchmarkCopyFat512 1307 329 -74.83% BenchmarkCopyFat256 666 169 -74.62% BenchmarkCopyFat1024 2617 671 -74.36% BenchmarkCopyFat128 343 89.0 -74.05% BenchmarkCopyFat64 182 48.9 -73.13% BenchmarkCopyFat32 103 28.8 -72.04% BenchmarkClearFat128 102 46.6 -54.31% BenchmarkClearFat512 344 167 -51.45% BenchmarkClearFat64 50.5 26.5 -47.52% BenchmarkClearFat256 147 87.2 -40.68% BenchmarkClearFat32 22.7 16.4 -27.75% BenchmarkClearFat1024 511 662 +29.55% Fixes #7624 LGTM=rsc R=golang-codereviews, khr, bradfitz, josharian, dave, rsc CC=golang-codereviews https://golang.org/cl/92760044
2014-04-16liblink, cmd/ld: reenable nosplit checking and testRuss Cox
The new code is adapted from the Go 1.2 nosplit code, but it does not have the bug reported in issue 7623: g% go run nosplit.go g% go1.2 run nosplit.go BUG rejected incorrectly: main 0 call f; f 120 linker output: # _/tmp/go-test-nosplit021064539 main.main: nosplit stack overflow 120 guaranteed after split check in main.main 112 on entry to main.f -8 after main.f uses 120 g% Fixes #6931. Fixes #7623. LGTM=iant R=golang-codereviews, iant, ality CC=golang-codereviews, r https://golang.org/cl/88190043
2014-04-14liblink: remove arch-specific constants from file formatRuss Cox
The relocation and automatic variable types were using arch-specific numbers. Introduce portable enumerations instead. To the best of my knowledge, these are the only arch-specific bits left in the new object file format. Remove now, before Go 1.3, because file formats are forever. LGTM=iant R=iant CC=golang-codereviews https://golang.org/cl/87670044
2014-03-11liblink: fix bad code generated for MOVFD/MOVDF when reg > 7Josh Bleecher Snyder
The byte that r is or'd into is already 0x7, so the failure to zero r only impacts the generated machine code if the register is > 7. Fixes #7044. LGTM=dave, minux.ma, rsc R=dave, minux.ma, bradfitz, rsc CC=golang-codereviews https://golang.org/cl/73730043
2014-02-03liblink, cmd/5l: restore flag_sharedElias Naur
CL 56120043 fixed and cleaned up TLS on ARM after introducing liblink, but left flag_shared broken. This CL restores the (unsupported) flag_shared behaviour by simply rewriting access to $runtime.tlsgm(SB) with runtime.tlsgm(SB), to compensate for the extra indirection when going from the R_ARM_TLS_LE32 relocation to the R_ARM_TLS_IE32 relocation. Also, remove unnecessary symbol lookup left after 56120043. LGTM=iant R=iant, rsc CC=golang-codereviews https://golang.org/cl/57000043
2014-01-23liblink, runtime: fix cgo on armRuss Cox
The addition of TLS to ARM rewrote the MRC instruction differently depending on whether we were using internal or external linking mode. That's clearly not okay, since we don't know that during compilation, which is when we now generate the code. Also, because the change did not introduce a real MRC instruction but instead just macro-expanded it in the assembler, liblink is rewriting a WORD instruction that may actually be looking for that specific constant, which would lead to very unexpected results. It was also using one value that happened to be 8 where a different value that also happened to be 8 belonged. So the code was correct for those values but not correct in general, and very confusing. Throw it all away. Replace with the following. There is a linker-provided symbol runtime.tlsgm with a value (address) set to the offset from the hardware-provided TLS base register to the g and m storage. Any reference to that name emits an appropriate TLS relocation to be resolved by either the internal linker or the external linker, depending on the link mode. The relocation has exactly the semantics of the R_ARM_TLS_LE32 relocation, which is what the external linker provides. This symbol is only used in two routines, runtime.load_gm and runtime.save_gm. In both cases it is now used like this: MRC 15, 0, R0, C13, C0, 3 // fetch TLS base pointer MOVW $runtime·tlsgm(SB), R2 ADD R2, R0 // now R0 points at thread-local g+m storage It is likely that this change breaks the generation of shared libraries on ARM, because the MOVW needs to be rewritten to use the global offset table and a different relocation type. But let's get the supported functionality working again before we worry about unsupported functionality. LGTM=dave, iant R=iant, dave CC=golang-codereviews https://golang.org/cl/56120043
2014-01-21liblink: remove use of linkmode on ARMRuss Cox
Now that liblink is compiled into the compilers and assemblers, it must not refer to the "linkmode", since that is not known until link time. This CL makes the ARM support no longer use linkmode, which fixes a bug with cgo binaries that contain their own TLS variables. The x86 code must also remove linkmode; that is issue 7164. Fixes #6992. R=golang-codereviews, iant CC=golang-codereviews https://golang.org/cl/55160043
2013-12-27all: fix a few spelling errors in source commentsMartin Olsson
R=golang-codereviews, dave, iant CC=golang-codereviews https://golang.org/cl/45750044
2013-12-18liblink: fix Plan 9 warningsDavid du Colombier
warning: src/liblink/asm5.c:485 non-interruptable temporary warning: src/liblink/asm5.c:565 set and not used: c warning: src/liblink/asm5.c:622 format mismatch ux VLONG, arg 2 warning: src/liblink/asm5.c:1218 overspecified class: asmout GLOBL STATIC warning: src/liblink/asm5.c:2088 overspecified class: oprrr GLOBL STATIC warning: src/liblink/asm5.c:2202 overspecified class: opbra GLOBL STATIC warning: src/liblink/asm5.c:2237 overspecified class: olr GLOBL STATIC warning: src/liblink/asm5.c:2266 overspecified class: olhr GLOBL STATIC warning: src/liblink/asm5.c:2291 overspecified class: osr GLOBL STATIC warning: src/liblink/asm5.c:2302 overspecified class: oshr GLOBL STATIC warning: src/liblink/asm5.c:2312 overspecified class: osrr GLOBL STATIC warning: src/liblink/asm5.c:2319 overspecified class: oshrr GLOBL STATIC warning: src/liblink/asm5.c:2325 overspecified class: olrr GLOBL STATIC warning: src/liblink/asm5.c:2332 overspecified class: olhrr GLOBL STATIC warning: src/liblink/asm5.c:2338 overspecified class: ofsr GLOBL STATIC warning: src/liblink/asm5.c:2375 overspecified class: omvl GLOBL STATIC warning: src/liblink/asm8.c:1261 format mismatch d VLONG, arg 3 warning: src/liblink/asm8.c:1274 format mismatch +d VLONG, arg 5 warning: src/liblink/list5.c:153 format mismatch d VLONG, arg 3 warning: src/liblink/list5.c:310 format mismatch d VLONG, arg 3 warning: src/liblink/obj6.c:665 set and not used: q warning: src/liblink/pcln.c:32 set and not used: p R=golang-dev, jas, gobot, rsc CC=golang-dev https://golang.org/cl/40370043
2013-12-16cmd/ld: move instruction selection + layout into compilers, assemblersRuss Cox
- new object file reader/writer (liblink/objfile.c) - remove old object file writing routines - add pcdata iterator - remove all trace of "line number stack" and "path fragments" from object files, linker (!!!) - dwarf now writes a single "compilation unit" instead of one per package This CL disables the check for chains of no-split functions that could overflow the stack red zone. A future CL will attack the problem of reenabling that check (issue 6931). This CL is just the liblink and cmd/ld changes. There are minor associated adjustments in CL 37030045. Each depends on the other. R=golang-dev, dave, iant CC=golang-dev https://golang.org/cl/39680043
2013-12-08liblink: create new library based on linker codeRuss Cox
There is an enormous amount of code moving around in this CL, but the code is the same, and it is invoked in the same ways. This CL is preparation for the new linker structure, not the new structure itself. The new library's definition is in include/link.h. The main change is the use of a Link structure to hold all the linker-relevant state, replacing the smattering of global variables. The Link structure should both make it clearer which state must be carried around and make it possible to parallelize more easily later. The main body of the linker has moved into the architecture-independent cmd/ld directory. That includes the list of known header types, so the distinction between Hplan9x32 and Hplan9x64 is removed (no other header type distinguished 32- and 64-bit formats), and code for unused formats such as ipaq kernels has been deleted. The code being deleted from 5l, 6l, and 8l reappears in liblink or in ld. Because multiple files are being merged in the liblink directory, it is not possible to show the diffs nicely in hg. The Prog and Addr structures have been unified into an architecture-independent form and moved to link.h, where they will be shared by all tools: the assemblers, the compilers, and the linkers. The unification makes it possible to write architecture-independent traversal of Prog lists, among other benefits. The Sym structures cannot be unified: they are too fundamentally different between the linker and the compilers. Instead, liblink defines an LSym - a linker Sym - to be used in the Prog and Addr structures, and the linker now refers exclusively to LSyms. The compilers will keep using their own syms but will fill out the corresponding LSyms in the Prog and Addr structures. Although code from 5l, 6l, and 8l is now in a single library, the code has been arranged so that only one architecture needs to be linked into a particular program: 5l will not contain the code needed for x86 instruction layout, for example. The object file writing code in liblink/obj.c is from cmd/gc/obj.c. Preparation for golang.org/s/go13linker work. This CL does not build by itself. It depends on 35740044 and will be submitted at the same time. R=iant CC=golang-dev https://golang.org/cl/35790044