aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ld/data.c
AgeCommit message (Collapse)Author
2011-07-19cgo: windows amd64 portWei Guangjing
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4725041
2011-07-18ld: allow seek within write bufferRuss Cox
Reduces number of write+seek's from 88516 to 2080 when linking godoc with 6l. Thanks to Alex Brainman for pointing out the many small writes. R=golang-dev, r, alex.brainman, robert.hencke CC=golang-dev https://golang.org/cl/4743043
2011-06-28ld: fix ELF strip by removing overlap of sectionsGustavo Niemeyer
The gosymtab and gopclntab sections were pointing to the proper data, but that data was already owned by the rodata section. Some ELF references explicitly prohibit multiple sections from owning the same data, and strip behaves accordingly. The data for these sections was moved to after rodata, and the gosymtab and gopclntab sections now own their respective ranges. This change makes strip happy both with and without -s being provided at link time. Note that it won't remove these sections because they are still allocated, and that's by design since they are necessary at runtime for generating proper backtraces and similar introspection operations. Unlike the previous behavior, -s will now maintain zero-sized gosymtab and gopclntab sections. This makes the implementation slightly cleaner. Fixes #1242. NOTE: Tested on Linux amd64/386/arm only. R=ality, rsc CC=golang-dev https://golang.org/cl/4639077
2011-06-22ld: don't attempt to build dynamic sections unnecessarilyGustavo Niemeyer
This prevents ld from generating zeroed symtab entries for sections that aren't going to be generated because dynamic linkage has been disabled (-d was used or no dynamic libs were seen). Even though they were not explicitly added by doelf, the section creation process was making them reachable again. The windows head is being disconsidered for this because apparently it's not taking into account debug['d']. This makes elflint 0.1% happier. R=golang-dev, rsc, gustavo CC=golang-dev https://golang.org/cl/4638050
2011-06-218l: more fixes for Plan 9Lucio De Re
Once these changes are effected, it is possible to construct "8l" native on a (386?) Plan 9 system, albeit with assistance from modules such as mkfiles that are not (yet) included in any public patches. 8l/asm.c: . Corrected some format qualifiers. 8l/list.c: . Cast a print() argument to (int) to match the given format. It may be possible to change the format (%R), but I have not looked into it. 8l/obj.c: . Removed some unused code. 8l/span.c: . Removed unnecessary incrementation on "bp". . Corrected some format qualifiers. ld/data.c: . Corrected some format qualifiers. . Cast print argument to (int): used as field size. . Use braces to suppress warning about empty if() statements. ld/dwarf.c: . Trivial spelling mistake in comment. ld/ldelf.c: . Added USED() statements to silence warnings. . Dropped redundant address (&) operators. . corrected some format qualifiers. . Cast to (int) for switch selection variable. ld/macho.c: . Added USED() statements to silence warnings. ld/ldpe.c: . Added USED() statements to silence warnings. . More careful use of "sect" variable. . Corrected some format qualifiers. . Removed redundant assignments. . Minor fix dropped as it was submitted separately. ld/pe.c: . Dropped <time.h> which is now in <u.h>. . Dropped redundant address (&) operators. . Added a missing variable initialisation. ld/symtab.c: . Added USED() statements to silence warnings. . Removed redundant incrementation. . Corrected some format qualifiers. All the above have been tested against a (very) recent release and do not seem to trigger any regressions. All review suggestions have been incorporated. R=rsc CC=golang-dev https://golang.org/cl/4633043
2011-06-14ld: make .rodata section read-onlyGustavo Niemeyer
Fixes the respective warning from elflint. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4607048
2011-06-14ld: fix link Windows PE __declspec(dllimport) symbolWei Guangjing
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4568077
2011-05-165l: delete pre-ARMv4 instruction implementationsRuss Cox
Add implementation for addr<->reg short moves. Align large data, for ARM. R=ken2 CC=golang-dev https://golang.org/cl/4545050
2011-05-11ld: fix alignment of rodata section on Plan 9Anthony Martin
This was causing a panic in the reflect package since type.* pointers with their low bits set are assumed to have certain flags set that disallow the use of reflection. Thanks to Pavel and Taru for help tracking down this bug. R=rsc, paulzhol, taruti CC=golang-dev https://golang.org/cl/4511041
2011-04-14for GCC4.6: fix a bunch of set-and-not-used errors.Rob Pike
R=rsc CC=golang-dev https://golang.org/cl/4406048
2011-04-14ld: defend against some broken object filesRuss Cox
Fixes #1698. Fixes #1699. R=ken2 CC=golang-dev https://golang.org/cl/4419041
2011-04-11ld: fix dwarf decoding of strings for struct's fieldnamesLuuk van Dijk
Moved Sym printing to Yconv. Fixed warning in data.c R=rsc CC=golang-dev https://golang.org/cl/4378052
2011-04-09ld: 25% fasterRuss Cox
The ld time was dominated by symbol table processing, so * increase hash table size * emit fewer symbols in gc (just 1 per string, 1 per type) * add read-only lookup to avoid creating spurious symbols * add linked list to speed whole-table traversals Breaks dwarf generator (no idea why), so disable dwarf. Reduces time for 6l to link godoc by 25%. R=ken2 CC=golang-dev https://golang.org/cl/4383047
2011-04-08ld: fix arm buildRuss Cox
R=ken2 CC=golang-dev, mikkel https://golang.org/cl/4384048
2011-04-07ld: fix Mach-O bss bugMikkel Krautz
Fixes #1559. R=rsc CC=golang-dev, peterGo, rog https://golang.org/cl/4356046
2011-03-09ld: preserve symbol sizes during data layoutRuss Cox
Fixes the broken linux/amd64 build. The symbol table, itself a symbol, was having its size rounded up to the nearest word boundary. If the rounding add >7 zero bytes then it confused the debug/gosym symbol table parser. So you've got a 1/8 chance to hit the bug on an amd64 system. Just started in the recent change because I fixed the rounding to round to word boundary instead of to 4-byte boundary. R=r CC=golang-dev https://golang.org/cl/4241056
2011-03-085l, 6l, 8l: omit symbols for type, string, go.stringRuss Cox
Much of the bulk of Go binaries is the symbol tables, which give a name to every C string, Go string, and reflection type symbol. These names are not worth much other than seeing what's where in a binary. This CL deletes all those names from the symbol table, instead aggregating the symbols into contiguous blocks and giving them the names "string.*", "go.string.*", and "type.*". Before: $ 6nm $(which godoc.old) | sort | grep ' string\.' | tail -10 59eda4 D string."aa87ca22be8b05378eb1c71... 59ee08 D string."b3312fa7e23ee7e4988e056... 59ee6c D string."func(*token.FileSet, st... 59eed0 D string."func(io.Writer, []uint8... 59ef34 D string."func(*tls.Config, *tls.... 59ef98 D string."func(*bool, **template.... 59effc D string."method(p *printer.print... 59f060 D string."method(S *scanner.Scann... 59f12c D string."func(*struct { begin in... 59f194 D string."method(ka *tls.ecdheRSA... $ After: $ 6nm $(which godoc) | sort | grep ' string\.' | tail -10 5e6a30 D string.* $ Those names in the "Before" are truncated for the CL. In the real binary they are the complete string, up to a certain length, or else a unique identifier. The same applies to the type and go.string symbols. Removing the names cuts godoc by more than half: -rwxr-xr-x 1 rsc rsc 9153405 2011-03-07 23:19 godoc.old -rwxr-xr-x 1 rsc rsc 4290071 2011-03-07 23:19 godoc For what it's worth, only 80% of what's left gets loaded into memory; the other 20% is dwarf debugging information only ever accessed by gdb: -rwxr-xr-x 1 rsc rsc 3397787 2011-03-07 23:19 godoc.nodwarf R=r, cw CC=golang-dev https://golang.org/cl/4245072
2011-02-235l/6l/8l: use enums for header type and symbolic strings for -H option valuesAlex Brainman
Thanks to rsc for the suggestion. R=r CC=golang-dev https://golang.org/cl/4174060
2011-01-20cgo: windows/386 portWei Guangjing
R=rsc, peterGo, brainman CC=golang-dev https://golang.org/cl/3733046
2011-01-206l: windows/amd64 portWei Guangjing
R=rsc CC=golang-dev https://golang.org/cl/3746044
2010-12-15ld: text segment should not be writableRuss Cox
R=adg CC=golang-dev https://golang.org/cl/3708041
2010-12-168l: remove unneeded windows checkAlex Brainman
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/3691042
2010-12-15fix freebsd buildRuss Cox
R=iant, r CC=dho, golang-dev https://golang.org/cl/3687041
2010-12-13Fix windows build.Wei Guangjing
R=brainman, rsc CC=golang-dev https://golang.org/cl/3533041
2010-12-125g/8g, 8l, ld, prof: fix output of 32-bit valuesEoghan Sherry
If an %lld argument can be 32 or 64 bits wide, cast to vlong. If always 32 bits, drop the ll. Fixes #1336. R=brainman, rsc CC=golang-dev https://golang.org/cl/3580041
2010-12-086l, 8l: support for linking ELF and Mach-O .o filesRuss Cox
More support for references to dynamic symbols, including full GOT and PLT for ELF objects. For Mach-O everything ends up in the GOT: dealing with the real lazy PLT is too hard for now so we punt. R=iant, iant2 CC=golang-dev https://golang.org/cl/3491042
2010-12-068l, runtime: fix Plan 9 386 build.Yuval Pavel Zholkover
8l was broken by commit 7ac0d2eed9, it caused .data to be page aligned in the file - which is not how Plan 9 expects things to be. Also .rodata was layed out in a similar fashion. Not sure when signame was introduced, but added a stub. Removed the symo assignment in asm.c as it is not currently used. Fix runtime breakage after commit 629c065d36 which prefixes all external symbols with runtimeĀ·. R=rsc CC=golang-dev https://golang.org/cl/2674041
2010-11-028l: pe generation fixesAlex Brainman
Restore ability to have different file and section alignment in generated pe file. Stop generating .bss pe section, it is part of .data now. Some code refactoring. R=rsc, vcc CC=golang-dev https://golang.org/cl/2731041
2010-10-225l, 6l, 8l: introduce sub-symbolsRuss Cox
Sub-symbols are laid out inside a larger symbol but can be addressed directly. Use to make Mach-O pointer array not a special case. Will use later to describe ELF sections. Glimpses of the beginning of ELF loading. R=ken2 CC=golang-dev https://golang.org/cl/2623043
2010-10-21arm: prop up software floating pointRuss Cox
Just enough to make mov instructions work, which in turn is enough to make strconv work when it avoids any floating point calculations. That makes a bunch of other packages pass their tests. Should suffice until hardware floating point is available. Enable package tests that now pass (some due to earlier fixes). Looks like there is a new integer math bug exposed in the fmt and json tests. R=ken2 CC=golang-dev https://golang.org/cl/2638041
2010-10-195l, 6l, 8l: link pclntab and symtab as ordinary rodata symbolsRuss Cox
That is, move the pc/ln table and the symbol table into the read-only data segment. This eliminates the need for a special load command to map the symbol table into memory, which makes the information available on systems that couldn't handle the magic load to 0x99000000, like NaCl and ARM QEMU and Linux without config_highmem=y. It also eliminates an #ifdef and some clumsy code to find the symbol table on Windows. The bad news is that the binary appears to be bigger than it used to be. This is not actually the case, though: the same amount of data is being mapped into memory as before, and the tables are still read-only, so they're still shared across multiple instances of the binary as they were before. The difference is just that the tables aren't squirreled away in some section that "size" doesn't know to look at. This is a checkpoint. It probably breaks Windows and breaks NaCl more than it used to be broken, but those will be fixed. The logic involving -s needs to be revisited too. Fixes #871. R=ken2 CC=golang-dev https://golang.org/cl/2587041
2010-10-195l, 6l, 8l: separate pass to fix addressesRuss Cox
Lay out code before data. R=ken2 CC=golang-dev https://golang.org/cl/2490043
2010-10-156l: function at a time code layoutRuss Cox
Also change the span-dependent jump algorithm to use fewer iterations: * resolve forward jumps at their targets (comefrom list) * mark jumps as small or big and only do small->big * record whether a jump failed to be encodable These changes mean that a function with only small jumps can be laid out in a single iteration, and the vast majority of functions take just two iterations. I was seeing a maximum of 5 iterations before; the max now is 3 and there are fewer that get even that far. R=ken2 CC=golang-dev https://golang.org/cl/2537041
2010-10-145l, 6l, 8l: accumulate data image during importRuss Cox
Using explicit relocations internally, we can represent the data for a particular symbol as an initialized block of memory instead of a linked list of ADATA instructions. The real goal here is to be able to hand off some of the relocations to the dynamic linker when interacting with system libraries, but a pleasant side effect is that the memory image is much more compact than the ADATA list, so the linkers use less memory. R=ken2 CC=golang-dev https://golang.org/cl/2512041