aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ld
AgeCommit message (Collapse)Author
2013-09-09build: remove various uses of C undefined behaviorRuss Cox
If you thought gcc -ansi -pedantic was pedantic, just wait until you meet clang -fsanitize=undefined. I think this addresses all the reported "errors", but we'll need another run to be sure. all.bash still passes. Update #5764 Dave, can you please try again? R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/13334049
2013-09-05cmd/ld: emit relocations for .debug_frame in external link modeIan Lance Taylor
This should have been part of revision 16731:cdedb129e020, but I missed it. This fixes printing local variables when doing an external link. No test because we aren't doing any debug info testing yet. Fixes #5719. R=golang-dev, r CC=golang-dev https://golang.org/cl/13464046
2013-09-04cgo: enable cgo on dragonflyAulus Egnatius Varialus
Enable cgo for dragonfly/386 and dragonfly/amd64. R=golang-dev, jsing, iant, bradfitz CC=golang-dev https://golang.org/cl/13247046
2013-09-04cmd/ld: don't allocate unused garbage space in pclntab file tableIan Lance Taylor
Fixes #6319. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/13539043
2013-08-31cmd/8l: add support for dragonfly/386Joel Sing
R=golang-dev, iant CC=golang-dev https://golang.org/cl/13328045
2013-08-30libbio, all cmd: consistently use BGETC/BPUTC instead of Bgetc/BputcDmitriy Vyukov
Also introduce BGET2/4, BPUT2/4 as they are widely used. Slightly improve BGETC/BPUTC implementation. This gives ~5% CPU time improvement on go install -a -p1 std. Before: real user sys 0m23.561s 0m16.625s 0m5.848s 0m23.766s 0m16.624s 0m5.846s 0m23.742s 0m16.621s 0m5.868s after: 0m22.999s 0m15.841s 0m5.889s 0m22.845s 0m15.808s 0m5.850s 0m22.889s 0m15.832s 0m5.848s R=golang-dev, r CC=golang-dev https://golang.org/cl/12745047
2013-08-29cmd/cc,runtime: change preprocessor to expand macros inside ofKeith Randall
#pragma textflag and #pragma dataflag directives. Update dataflag directives to use symbols instead of integer constants. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/13310043
2013-08-24all: compiler/bootstrap for dragonfly/amd64Joel Sing
Add dragonfly/amd64 support to the Go compiler, bootstrap and GOOS list. R=devon.odell, bradfitz CC=golang-dev https://golang.org/cl/12796050
2013-08-14cmd/ld: Remove superfluous redundant iself checkElias Naur
CL 12741044 added an extra iself condition to an if statement that already contained it. Remove it. R=rsc CC=golang-dev https://golang.org/cl/12949043
2013-08-14cmd/dist: fix darwin buildRuss Cox
The TLS block on Darwin is not the same as on ELF. TBR=elias.naur CC=golang-dev https://golang.org/cl/12741044
2013-08-14runtime.cmd/ld: Add ARM external linking and implement -shared in terms of ↵Elias Naur
external linking This CL is an aggregate of 10271047, 10499043, 9733044. Descriptions of each follow: 10499043 runtime,cmd/ld: Merge TLS symbols and teach 5l about ARM TLS This CL prepares for external linking support to ARM. The pseudo-symbols runtime.g and runtime.m are merged into a single runtime.tlsgm symbol. When external linking, the offset of a thread local variable is stored at a memory location instead of being embedded into a offset of a ldr instruction. With a single runtime.tlsgm symbol for both g and m, only one such offset is needed. The larger part of this CL moves TLS code from gcc compiled to internally compiled. The TLS code now uses the modern MRC instruction, and 5l is taught about TLS fallbacks in case the instruction is not available or appropriate. 10271047 This CL adds support for -linkmode external to 5l. For 5l itself, use addrel to allow for D_CALL relocations to be handled by the host linker. Of the cases listed in rsc's comment in issue 4069, only case 5 and 63 needed an update. One of the TODO: addrel cases was since replaced, and the rest of the cases are either covered by indirection through addpool (cases with LTO or LFROM flags) or stubs (case 74). The addpool cases are covered because addpool emits AWORD instructions, which in turn are handled by case 11. In the runtime, change the argv argument in the rt0* functions slightly to be a pointer to the argv list, instead of relying on a particular location of argv. 9733044 The -shared flag to 6l outputs a shared library, implemented in Go and callable from non-Go programs such as C. The main part of this CL change the thread local storage model. Go uses the fastest and least general mode, local exec. TLS data in shared libraries normally requires at least the local dynamic mode, however, this CL instead opts for using the initial exec mode. Initial exec mode is faster than local dynamic mode and can be used in linux since the linker has reserved a limited amount of TLS space for performance sensitive TLS code. Initial exec mode requires an extra load from the GOT table to determine the TLS offset. This penalty will not be paid if ld is not in -shared mode, since TLS accesses will be reduced to local exec. The elf sections .init_array and .rela.init_array are added to register the Go runtime entry with cgo at library load time. The "hidden" attribute is added to Cgo functions called from Go, since Go does not generate call through the GOT table, and adding non-GOT relocations for a global function is not supported by gcc. Cgo symbols don't need to be global and avoiding the GOT table is also faster. The changes to 8l are only removes code relevant to the old -shared mode where internal linking was used. This CL only address the low level linker work. It can be submitted by itself, but to be useful, the runtime changes in CL 9738047 is also needed. Design discussion at https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/zmjXkGrEx6Q Fixes #5590. R=rsc CC=golang-dev https://golang.org/cl/12871044
2013-08-07cmd/ld: Put the textflag constants in a separate file.Keith Randall
We can then include this file in assembly to replace cryptic constants like "7" with meaningful constants like "(NOPROF|DUPOK|NOSPLIT)". Converting just pkg/runtime/asm*.s for now. Dropping NOPROF and DUPOK from lots of places where they aren't needed. More .s files to come in a subsequent changelist. A nonzero number in the textflag field now means "has not been converted yet". R=golang-dev, daniel.morsing, rsc, khr CC=golang-dev https://golang.org/cl/12568043
2013-08-02runtime: reimplement reflect.call to not use stack splitting.Keith Randall
R=golang-dev, r, khr, rsc CC=golang-dev https://golang.org/cl/12053043
2013-08-01cmd/ld: report pclntab, funcdata sizes in 6l -v outputRuss Cox
Also move chatty recent additions to -v -v. For what it's worth: $ go build -o /dev/null -ldflags -v cmd/go ... 0.87 pclntab=1110836 bytes, funcdata total 69700 bytes ... $ This broke the ELF builds last time because I tried to dedup the funcdata in case the same funcdata was pointed at by multiple functions. That doesn't currently happen, so I've removed that test. If we start doing bitmap coalescing we'll need to figure out how to measure the size more carefully, but I think at that point the bitmaps will be an extra indirection away from the funcdata anyway, so the dedup I used before wouldn't help. R=ken2 CC=golang-dev https://golang.org/cl/12269043
2013-07-31undo CL 12193043 / cc5858966b08Brad Fitzpatrick
Breaks all ELF builds. ««« original CL description cmd/ld: report pclntab, funcdata sizes in 6l -v output Also move chatty recent additions to -v -v. For what it's worth: $ go build -o /dev/null -ldflags -v cmd/godoc ... 0.73 pclntab=1259976 bytes, funcdata total 79788 bytes ... $ R=ken2 CC=cshapiro, golang-dev https://golang.org/cl/12193043 »»» R=rsc CC=golang-dev https://golang.org/cl/12202043
2013-07-31 cmd/ld: report pclntab, funcdata sizes in 6l -v outputRuss Cox
Also move chatty recent additions to -v -v. For what it's worth: $ go build -o /dev/null -ldflags -v cmd/godoc ... 0.73 pclntab=1259976 bytes, funcdata total 79788 bytes ... $ R=ken2 CC=cshapiro, golang-dev https://golang.org/cl/12193043
2013-07-22cmd/ld: fix warnings on Plan 9David du Colombier
src/cmd/ld/lib.c:1379 set and not used: p src/cmd/ld/lib.c:1426 format mismatch 6llux INT, arg 3 src/cmd/ld/lib.c:1437 format mismatch 6llux INT, arg 3 src/cmd/ld/lib.c:1456 format mismatch 6llux INT, arg 3 src/cmd/ld/lib.c:1477 format mismatch 6llux INT, arg 3 src/cmd/ld/lib.c:1459 set and not used: started R=golang-dev, rsc CC=golang-dev https://golang.org/cl/11615044
2013-07-19cmd/ld, runtime: remove unused fields from FuncRuss Cox
R=golang-dev, r CC=golang-dev https://golang.org/cl/11604043
2013-07-19cmd/gc, cmd/ld: fix build: remove unused var, use correct var in printfIan Lance Taylor
Fixes #5924. R=golang-dev, khr, rsc CC=golang-dev https://golang.org/cl/11606043
2013-07-19runtime: use funcdata to supply garbage collection informationRuss Cox
This CL introduces a FUNCDATA number for runtime-specific garbage collection metadata, changes the C and Go compilers to emit that metadata, and changes the runtime to expect it. The old pseudo-instructions that carried this information are gone, as is the linker code to process them. R=golang-dev, dvyukov, cshapiro CC=golang-dev https://golang.org/cl/11406044
2013-07-19runtime: cleanup: use ArgsSizeUnknown to mark all functionsKeith Randall
whose argument size is unknown (C vararg functions, and assembly code without an explicit specification). We used to use 0 to mean "unknown" and 1 to mean "zero". Now we use ArgsSizeUnknown (0x80000000) to mean "unknown". R=golang-dev, rsc CC=golang-dev https://golang.org/cl/11590043
2013-07-18cmd/ld: refine test for history stack pop (fix Windows build)Russ Cox
This should fix the Windows build, or at least what's breaking it at the moment. Fixes #5904. TBR=golang-dev CC=golang-dev https://golang.org/cl/11519044
2013-07-18cmd/ld, runtime: use new contiguous pcln tableRuss Cox
R=golang-dev, r, dave CC=golang-dev https://golang.org/cl/11494043
2013-07-18cmd/ld: trivial: fix unused parameter pedantryDave Cheney
R=golang-dev, r, rsc CC=golang-dev https://golang.org/cl/11436043
2013-07-16cmd/ld, runtime: new in-memory symbol table formatRuss Cox
Design at http://golang.org/s/go12symtab. This enables some cleanup of the garbage collector metadata that will be done in future CLs. This CL does not move the old symtab and pclntab back into an unmapped section of the file. That's a bit tricky and will be done separately. Fixes #4020. R=golang-dev, dave, cshapiro, iant, r CC=golang-dev, nigeltao https://golang.org/cl/11085043
2013-07-11cmd/ld: place read-only data in non-executable segmentRuss Cox
R=golang-dev, dave, r CC=golang-dev, nigeltao https://golang.org/cl/10713043
2013-07-10cmd/ld: correct assignment of sizes to mach-o symbolsRuss Cox
If you compute the size by subtraction from the address of the next symbol, it helps to wait until the symbols have been sorted by address. R=golang-dev, r CC=golang-dev https://golang.org/cl/11143043
2013-07-08cmd/ld: trivial: fix unhandled switch caseDave Cheney
Fix warning found by clang 3.3. R=rsc, r CC=golang-dev https://golang.org/cl/11022043
2013-06-25cmd/ld: fix line numbers when using fieldtrackRuss Cox
USEFIELD is a special kind of NOP, so treat it like a NOP when generating the pc-ln table. There are more invasive fixes that could be applied here. I am going for minimum number of lines changed. The smallest test case we know of is five distinct Go files in four packages, and the bug only happens with GOEXPERIMENT=fieldtrack enabled, which we don't normally build with, so the test would never run meaningfully anyway. Fixes #5762. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/10495044
2013-06-12cmd/ld: supply -s to gcc if -s is passed.Shenghou Ma
Fixes #5463. R=golang-dev, iant CC=golang-dev https://golang.org/cl/9239045
2013-06-11cmd/ld: document -s flag.Shenghou Ma
R=golang-dev, iant CC=golang-dev https://golang.org/cl/10159043
2013-06-09all: fix typosShenghou Ma
R=golang-dev, bradfitz, khr, r CC=golang-dev https://golang.org/cl/7461046
2013-06-04cmd/ld: fix gcdata and gcbss symbolsAnthony Martin
These two symbols don't show up in the Go symbol table since they're defined in dodata which is called sometime after symtab. They do, however, show up in the ELF symbol table. This regression was introduced in changeset 01c40d533367. Also, remove the corresponding strings from the ELF strtab section now that they're unused. R=golang-dev, iant CC=golang-dev https://golang.org/cl/8650043
2013-06-03cmd/ld, runtime: clean up CL 9666047Russ Cox
Remove unnecessary ( ) around == in && clause. Add { } around multiline if body, even though it's one statement. Add runtime: prefix to printed errors. R=cshapiro, iant CC=golang-dev https://golang.org/cl/9685047
2013-05-29cmd/ld, runtime: emit pointer maps for nosplits identified by the linkerCarl Shapiro
A nosplits was assumed to have no argument information and no pointer map. However, nosplits created by the linker often have both. This change uses the pointer map size as an alternate source of argument size when processing a nosplit. In addition, the symbol table construction pointer map size and argument size consistency check is strengthened. If a nptrs is greater than 0 it must be equal to the number of argument words. R=golang-dev, khr, khr CC=golang-dev https://golang.org/cl/9666047
2013-05-28cmd/5l, cmd/6l, cmd/8l, cmd/gc, runtime: generate and use bitmaps of ↵Carl Shapiro
argument pointer locations With this change the compiler emits a bitmap for each function covering its stack frame arguments area. If an argument word is known to contain a pointer, a bit is set. The garbage collector reads this information when scanning the stack by frames and uses it to ignores locations known to not contain a pointer. R=golang-dev, bradfitz, daniel.morsing, dvyukov, khr, khr, iant, cshapiro CC=golang-dev https://golang.org/cl/9223046
2013-05-18cmd/ld: emit .tbss section when doing dynamic internal linkingShenghou Ma
Fixes #5200. R=iant, dave CC=golang-dev https://golang.org/cl/9383043
2013-05-03cmd/ld: add .note.GNU-stack section for external linkingShenghou Ma
Fixes #5392. R=iant, r CC=golang-dev https://golang.org/cl/9119043
2013-05-02cmd/ld: fix SDYNIMPORT symbol testAlex Brainman
As advised by iant. Fixes windows build. R=golang-dev, r CC=golang-dev, iant https://golang.org/cl/9110044
2013-05-01cmd/ld: fix another unsigned value causing bugs on Plan 9Rob Pike
"The usual conversions" bite again. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/9103044
2013-05-01cmd/ld: fix syms that are both cgo_import_static & cgo_import_dynamicIan Lance Taylor
This is needed for SWIG when linking in internal mode. In internal mode if a symbol was cgo_import_static we used to forget that it was also cgo_import_dynamic. R=rsc, r CC=golang-dev https://golang.org/cl/9080043
2013-04-30cmd/ld: when linking externally, only generate dwarf info for ELFRob Pike
R=golang-dev, iant CC=golang-dev https://golang.org/cl/9025047
2013-04-30cmd/ld: emit relocs for DWARF info when doing an external linkIan Lance Taylor
I would like opinions on whether this is a good idea for 1.1. On the one hand it's a moderately important issue. On the other hand this introduces at least the possibility of external linker errors due to the additional relocations and it may be better to wait. I'm fairly confident that the behaviour is unchanged when not using an external linker. Update #5221 This CL is tested lightly on 386 and amd64 and fixes the cases I tested. I have not tested it on Darwin or Windows. R=golang-dev, dave, daniel.morsing, rsc CC=golang-dev https://golang.org/cl/8858047
2013-04-30cmd/ld: another attempt at the relocation overflow fixRob Pike
R=golang-dev, iant CC=golang-dev https://golang.org/cl/9036046
2013-04-30cmd/ld: fix check for address wrap in relocationRob Pike
PC-relative needs a signed offset; others need unsigned. Also fix signedness of 32-bit relocation on Windows. R=golang-dev, iant CC=golang-dev https://golang.org/cl/9039045
2013-04-30cmd/ld: disable relocation range check so build can go green while we debug ↵Rob Pike
the issue. R=golang-dev, dsymonds, dave CC=golang-dev https://golang.org/cl/9038043
2013-04-29cmd/ld: fix some 64-bit issuesRob Pike
A few places in the linker pushed 64-bit values through 32-bit holes, including in relocation. Clean them up, and check for a few other overflows as well. Tests to follow. R=dsymonds CC=gobot, golang-dev https://golang.org/cl/9032043
2013-04-20cmd/ld: do not relocate ignored PE sectionsAlex Brainman
This should have been part of CL8715043. Update #5106 R=golang-dev, r, iant CC=golang-dev https://golang.org/cl/8676050
2013-04-20cmd/ld: don't show cursym in gcc invocation failure messageShenghou Ma
before: fmt.statictmp_0731:/usr/local/go/pkg/tool/linux_amd64/6l: running gcc failed: unsuccessful exit status 0x100 now: /usr/local/go/pkg/tool/linux_amd64/6l: running gcc failed: unsuccessful exit status 0x100 R=golang-dev, iant, r CC=golang-dev https://golang.org/cl/8827045
2013-04-15cmd/ld: ignore PE sections that are not code or dataIan Lance Taylor
Update #5106 Update #5273 R=minux.ma, r CC=golang-dev https://golang.org/cl/8715043