1
0
mirror of https://github.com/golang/go synced 2024-10-04 07:21:22 -06:00
Commit Graph

193 Commits

Author SHA1 Message Date
Alex Brainman
eaa082f691 8l: minor fix discovered by lucio
R=lucio.dere, vcc.163, bradfitz
CC=golang-dev
https://golang.org/cl/4645044
2011-06-17 15:55:54 +10:00
Lucio De Re
340251e43d build: fix header files for Plan 9
The "elf.h" header changes involve only comments, the released
Plan 9 C preprocessing function does not cope with multiline
comments following the #define keyword.  All multiline comments
have been moved to the line above the associated definition.
Sigh!  Fixing the Plan 9 compiler is not an option.

<time.h> does not exist in the Plan 9 Native library.  I have
moved it from src/cmd/ld/pe.h to include/u.h. RSC correctly points
out that this copy of <u.h> is not the one used to compile the
Go release on Plan 9 platforms.

R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/4574042
2011-06-14 14:14:11 -04:00
Gustavo Niemeyer
a84e9d01f0 ld: make .rodata section read-only
Fixes the respective warning from elflint.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4607048
2011-06-14 15:13:54 -03:00
Wei Guangjing
9e2ffc315f ld: fix link Windows PE __declspec(dllimport) symbol
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4568077
2011-06-14 11:05:59 -04:00
Luuk van Dijk
d164b6081d ld: dwarf emit filenames in debug_line header instead of as extended opcodes.
Makes it possible for older tools like objdump to find the filenames,
fixes  objdump -d -l --start-address=0x400c00 --stop-address=0x400c36 6.out
fixes #1950

R=rsc
CC=golang-dev
https://golang.org/cl/4609043
2011-06-13 16:56:43 +02:00
Russ Cox
1fddbab736 5l: fix softfloat nits
Need to load math.a so that sqrtGoC is available.
Also was missing prototype.

R=ken2
CC=golang-dev
https://golang.org/cl/4517148
2011-06-09 18:38:25 -04:00
Anthony Martin
c5030e5f4b ld: fix and simplify ELF symbol generation
I started looking at this code because the nm in GNU
binutils was ignoring the first symbol in the .symtab
section.  Apparently, the System V ABI reserves the
first entry and requires all fields inside to be set
to zero.

The list of changes is as follows:

  · reserve the first symbol entry (as noted above)
  · fix the section indices for .data and .bss symbols
  · factor out common code for Elf32 and Elf64
  · remove the special case for elfsymo in [568]l/asm.c:/^asmb
  · add the "etext" symbol in 6l
  · add static symbols

R=rsc
CC=golang-dev
https://golang.org/cl/4524075
2011-06-07 14:26:16 -04:00
Lucio De Re
9baaa6f742 8l, ld: Initial adjustments for Plan 9 native compilation of 8l
These changes are not particularly invasive and have been tested
as broadly as possible.

8l/l.h:
  -	#pragma varargck: added some, removed duplicates.

ld/dwarf.c:
  -	As Plan 9 has no NULL, changed all occurrences to nil.
  -	Added USED(size); where necessary.
  -	Added (void) argument in definition of finddebugruntimepath().
  -	Plan 9 compiler was complaining about multiple
        assignments, repeaired by breaking up the commands.
  -	Correction: havedynamic = 1; restored.

ld/go.c:
  -	Needed USED(file); in two functions.
  -	Removed unused assignments flagged by the Plan 9 compiler.

ld/lib.c:
  -	Replaced unlink() with remove() which seems available everywhere.
  -	Removed USED(c4); and USED(magic) no longer required.
  -	Removed code flagged as unused by the Plan 9 compiler.
  -	Added attributes to a number of format strings.

R=rsc
CC=golang-dev
https://golang.org/cl/4435047
2011-06-03 13:20:31 -04:00
Russ Cox
831c684434 5l: fix build
R=ken2
CC=golang-dev
https://golang.org/cl/4538095
2011-05-25 09:44:05 -04:00
Russ Cox
64b497c62a ld: add -w to disable dwarf, make errors obviously from dwarf
Reenable dwarf output on Mac.
Was writing headers but no actual dwarf data.

Fixes #1877 (accidentally).
Workaround for issue 1878.

R=lvd
CC=golang-dev
https://golang.org/cl/4515139
2011-05-25 08:25:33 -04:00
Wei Guangjing
2ad58d48fb 8l: emit resources (.rsrc) in Windows PE.
R=alex.brainman, rsc
CC=golang-dev, vcc.163
https://golang.org/cl/4516055
2011-05-25 07:53:00 -04:00
Russ Cox
d2b2b3f4a8 6l, 8l: fix Mach-O binaries with many dynamic libraries
R=ken2
CC=golang-dev
https://golang.org/cl/4529084
2011-05-24 19:50:13 -04:00
Russ Cox
40745a579c 5l: delete pre-ARMv4 instruction implementations
Add implementation for addr<->reg short moves.
Align large data, for ARM.

R=ken2
CC=golang-dev
https://golang.org/cl/4545050
2011-05-16 16:14:37 -04:00
Alex Brainman
34ac4ec30c 6l, 8l: emit windows dwarf sections similar to other platforms
R=golang-dev, rsc
CC=golang-dev, vcc.163
https://golang.org/cl/4517056
2011-05-13 16:05:47 +10:00
Russ Cox
70798eaad6 5l, 8l: add ELF symbol table to binary
Should have been added long ago.
Thanks to Alex Brainman for noticing.

R=ken2
CC=golang-dev
https://golang.org/cl/4538046
2011-05-11 23:59:36 -04:00
Anthony Martin
4fca395321 ld: fix alignment of rodata section on Plan 9
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-05-11 23:52:05 -04:00
Russ Cox
296d6871a8 ld: make ELF binaries with no shared library dependencies static binaries
$ file $GOROOT/bin/{godoc,goyacc}
/home/rsc/g/go/bin/godoc:  ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not strpped
/home/rsc/g/go/bin/goyacc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
$

Fixes #1758.

R=iant
CC=golang-dev
https://golang.org/cl/4428079
2011-05-03 01:56:23 -04:00
Russ Cox
09092a78e6 cgo: handle versioned ELF symbols
Fixes #1397.

R=iant
CC=golang-dev
https://golang.org/cl/4444064
2011-04-27 23:21:03 -04:00
Alex Brainman
2d99974ec5 8l: do not emit empty dwarf pe sections
This change will allow to generate valid executable,
even if rsc disables dwarf generation, as it happend
at revision 9a64273f9d68.

R=rsc
CC=golang-dev, lvd, vcc
https://golang.org/cl/4425066
2011-04-26 17:12:16 +10:00
Russ Cox
c2c7ee2736 ld: fix 6l -d on Mac, diagnose invalid use of -d
R=r
CC=golang-dev
https://golang.org/cl/4430064
2011-04-25 13:57:52 -04:00
Anthony Martin
c7008f47ec ld: fix Plan 9 symbol table
Static symbols were not being marked as such.

I also made the 'z' symbols use the first byte of
the name instead of an explicit NUL so that if
the symbol table format is ever changed, the only
place that would need updating is addhist().

R=rsc
CC=golang-dev
https://golang.org/cl/4366047
2011-04-23 10:53:49 -04:00
Russ Cox
047e698c52 ld: remove MachoLoad limit
Fixes #1571.

R=ken2
CC=golang-dev
https://golang.org/cl/4443052
2011-04-20 16:25:00 -04:00
Rob Pike
a89c0ff39e for GCC4.6: fix a bunch of set-and-not-used errors.
R=rsc
CC=golang-dev
https://golang.org/cl/4406048
2011-04-14 13:31:37 -07:00
Russ Cox
bd43a2d9ff ld: defend against some broken object files
Fixes #1698.
Fixes #1699.

R=ken2
CC=golang-dev
https://golang.org/cl/4419041
2011-04-14 10:42:48 -04:00
Luuk van Dijk
dd93df35b9 runtime: fix gdb support for channels.
R=rsc
CC=golang-dev
https://golang.org/cl/4418043
2011-04-14 15:32:20 +02:00
Russ Cox
507df959e4 runtime: drop chan circular linked list in favor of circular buffer
The list elements are already being allocated out of a
single memory buffer.  We can drop the Link* pointer
following and the memory it requires, replacing it with
index operations.

The change also keeps a channel from containing a pointer
back into its own allocation block, which would create a
cycle.  Blocks involved in cycles are not guaranteed to be
finalized properly, and channels depend on finalizers to
free OS-level locks on some systems.  The self-reference
was keeping channels from being garbage collected.

runtime-gdb.py will need to be updated in order to dump
the content of buffered channels with the new data structure.

Fixes #1676.

R=ken2, r
CC=golang-dev
https://golang.org/cl/4411045
2011-04-13 23:42:06 -04:00
Lucio De Re
11e07d23ed ld: ELF header function declarations.
Added "void" inside "()" for two functions.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4381056
2011-04-12 11:00:09 -07:00
Luuk van Dijk
0cc055e8f7 ld: fix dwarf decoding of strings for struct's fieldnames
Moved Sym printing to Yconv.
Fixed warning in data.c

R=rsc
CC=golang-dev
https://golang.org/cl/4378052
2011-04-11 16:38:37 -04:00
Russ Cox
1bc84b7e18 ld: 25% faster
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-09 09:44:20 -04:00
Russ Cox
d26e73646e ld: fix arm build
R=ken2
CC=golang-dev, mikkel
https://golang.org/cl/4384048
2011-04-08 13:42:11 -04:00
Mikkel Krautz
2aceea630f ld: fix Mach-O X86_64_RELOC_SIGNED relocations
Fixes #1658.

R=rsc
CC=golang-dev
https://golang.org/cl/4344066
2011-04-07 14:20:42 -04:00
Mikkel Krautz
cf3323f511 ld: fix Mach-O bss bug
Fixes #1559.

R=rsc
CC=golang-dev, peterGo, rog
https://golang.org/cl/4356046
2011-04-07 13:17:28 -04:00
Andrew Gerrand
d4b19bdbed ld: return > 0 exit code on unsafe import
R=rsc
CC=golang-dev
https://golang.org/cl/4273092
2011-03-22 15:00:21 +11:00
Russ Cox
f0ab14647a ld: preserve symbol sizes during data layout
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-09 11:18:29 -05:00
Russ Cox
7a09a88274 5l, 6l, 8l: omit symbols for type, string, go.string
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-03-08 14:14:28 -05:00
Luuk van Dijk
da42312268 6l,8l: fix gdb crash.
DWARF function types no longer need to be pointer-ified explicitly.
Fixes #1579.

R=rsc, lvd1
CC=golang-dev
https://golang.org/cl/4247065
2011-03-08 18:28:42 +01:00
Russ Cox
44fd7573aa gc, ld: reflect support for PtrTo
R=ken2
CC=golang-dev
https://golang.org/cl/4245055
2011-03-03 13:17:54 -05:00
Russ Cox
8d36a78440 reflect: add pointer word to CommonType
The pointer will eventually let us find *T given T.
This CL just makes room for it, always storing a zero.

R=r, r2
CC=golang-dev
https://golang.org/cl/4221046
2011-02-24 17:11:20 -05:00
Russ Cox
d94bf76239 ld: weak symbols
A reference to the address of weak.foo resolves at link time
to the address of the symbol foo if foo would end up in the
binary anyway, or to zero if foo would not be in the binary.

For example:

        int xxx = 1;
        int yyy = 2;
        int weak·xxx;
        int weak·yyy;

        void main·main(void) {
                runtime·printf("%p %p %p\n", &xxx, &weak·xxx, &weak·yyy);
        }

prints the same non-nil address twice, then 0 (because yyy is not
referenced so it was dropped from the binary).

This will be used by the reflection tables.

R=iant
CC=golang-dev
https://golang.org/cl/4223044
2011-02-24 16:45:45 -05:00
Alex Brainman
75fb2f6c82 8l/6l: new -Hwindowsgui flag allows to build windows gui pe
Fixes #1516.

R=rsc, mattn
CC=golang-dev
https://golang.org/cl/4214041
2011-02-24 16:10:30 +11:00
Alex Brainman
0cf6f8c096 5l/6l/8l: use enums for header type and symbolic strings for -H option values
Thanks to rsc for the suggestion.

R=r
CC=golang-dev
https://golang.org/cl/4174060
2011-02-23 14:30:40 +11:00
Russ Cox
d9fd11443c ld: detect stack overflow due to NOSPLIT
Fix problems found.

On amd64, various library routines had bigger
stack frames than expected, because large function
calls had been added.

runtime.assertI2T: nosplit stack overflow
        120	assumed on entry to runtime.assertI2T
        8	after runtime.assertI2T uses 112
        0	on entry to runtime.newTypeAssertionError
        -8	on entry to runtime.morestack01

runtime.assertE2E: nosplit stack overflow
        120	assumed on entry to runtime.assertE2E
        16	after runtime.assertE2E uses 104
        8	on entry to runtime.panic
        0	on entry to runtime.morestack16
        -8	after runtime.morestack16 uses 8

runtime.assertE2T: nosplit stack overflow
        120	assumed on entry to runtime.assertE2T
        16	after runtime.assertE2T uses 104
        8	on entry to runtime.panic
        0	on entry to runtime.morestack16
        -8	after runtime.morestack16 uses 8

runtime.newselect: nosplit stack overflow
        120	assumed on entry to runtime.newselect
        56	after runtime.newselect uses 64
        48	on entry to runtime.printf
        8	after runtime.printf uses 40
        0	on entry to vprintf
        -8	on entry to runtime.morestack16

runtime.selectdefault: nosplit stack overflow
        120	assumed on entry to runtime.selectdefault
        56	after runtime.selectdefault uses 64
        48	on entry to runtime.printf
        8	after runtime.printf uses 40
        0	on entry to vprintf
        -8	on entry to runtime.morestack16

runtime.selectgo: nosplit stack overflow
        120	assumed on entry to runtime.selectgo
        0	after runtime.selectgo uses 120
        -8	on entry to runtime.gosched

On arm, 5c was tagging functions NOSPLIT that should
not have been, like the recursive function printpanics:

printpanics: nosplit stack overflow
        124	assumed on entry to printpanics
        112	after printpanics uses 12
        108	on entry to printpanics
        96	after printpanics uses 12
        92	on entry to printpanics
        80	after printpanics uses 12
        76	on entry to printpanics
        64	after printpanics uses 12
        60	on entry to printpanics
        48	after printpanics uses 12
        44	on entry to printpanics
        32	after printpanics uses 12
        28	on entry to printpanics
        16	after printpanics uses 12
        12	on entry to printpanics
        0	after printpanics uses 12
        -4	on entry to printpanics

R=r, r2
CC=golang-dev
https://golang.org/cl/4188061
2011-02-22 17:40:40 -05:00
Russ Cox
afac1c2654 ld: drop rpath
Was required by old cgo but we don't
generate stub .so files anymore.

Update #1527.

R=iant
CC=golang-dev
https://golang.org/cl/4168056
2011-02-18 11:35:36 -05:00
Wei Guangjing
8ba4df2e9a 6l: pe fixes
R=rsc, brainman
CC=golang-dev
https://golang.org/cl/4182061
2011-02-18 10:58:47 +11:00
Alex Brainman
074354c2ea 8l,6l: allow for more os threads to be created on Windows
Program listed http://code.google.com/p/go/issues/detail?id=1495
(with nRequester set to 10000) will crash with

runtime: failed to create new OS thread (have 4526 already; errno=8)

instead of

runtime: failed to create new OS thread (have 618 already; errno=8).

R=golang-dev, rsc, vcc
CC=golang-dev
https://golang.org/cl/4172046
2011-02-16 16:08:42 +11:00
Rob Pike
0ae041735a ld: fix build (uvlong vs uint64 conflict on freebsd)
R=rsc
CC=golang-dev
https://golang.org/cl/4023071
2011-02-07 14:40:36 -08:00
Rob Pike
fb55941539 loader: move the XputY routines into the ld directory.
Fixes the build for 5l, and also removes an inconsequential bug in 8l.

R=rsc
CC=golang-dev
https://golang.org/cl/4127051
2011-02-07 14:34:21 -08:00
Yuval Pavel Zholkover
c14c4e55e0 8l: fix crash writing Plan 9 binaries
Was crashing with GOOS=plan9 unless -s was passed.
Add symbols and line numbers to Plan 9 a.out.

R=rsc
CC=golang-dev
https://golang.org/cl/4080050
2011-02-04 14:33:21 -05:00
Russ Cox
c1a695c160 gc, ld: package name main no longer reserved
R=ken2
CC=golang-dev
https://golang.org/cl/4128054
2011-02-03 14:17:20 -05:00
Russ Cox
3f61184e1b gc, ld: detect stale or incompatible object files
The object files begin with a header that is

        $GOARCH

on a line by itself.  This CL changes that header to

        go object $GOOS $GOARCH release.2011-01-01 4567+

where the final two fields are the most recent release
tag and the current hg version number.

All objects imported into a Go compilation or linked into an
executable must have the same header line, and that header
line must match the compiler and linker versions.

The effect of this will be that if you update and run all.bash
and then try to link in objects compiled with an earlier version
of the compiler (or invoke the wrong version of the compiler),
you will get an error showing the different headers instead
of perhaps silent incompatibility.

Normal usage with all.bash should be unaffected, because
all.bash deletes all the object files in $GOROOT/pkg/$GOOS_$GOARCH
and cleans all intermediate object files before starting.

This change is intended to diagnose stale objects arising when
users maintaining alternate installation directories forget to
rebuild some of their files after updating.

It should help make the adoption of $GOPATH (CL 3780043)
less error-prone.

R=ken2, r
CC=golang-dev
https://golang.org/cl/4023063
2011-02-03 13:51:43 -05:00