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
The solution may be a bit of a sledgehammer, but it looks like
a temporary situation anyway.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4400042
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
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
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
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
Shame on me: I fixed the same bug in 6l in 8691fcc6a66e
(https://golang.org/cl/2609041) and neglected
to look at 5l and 8l to see if they were affected.
On the positive side, the check I added in that CL is the
one that detected this bug.
Fixes#1457.
R=ken2
CC=golang-dev
https://golang.org/cl/3981052
#pragma dynexport is no longer needed for
this use of cgo, since the gcc and gc code are
now linked together into the same binary.
It may still be necessary later.
On the Mac, you cannot use the GOT to resolve
symbols that exist in the current binary, so 6l and 8l
translate the GOT-loading mov instructions into lea
instructions.
On ELF systems, we could use the GOT for those
symbols, but for consistency 6l and 8l apply the
same translation.
The translation is sketchy in the extreme
(depending on the relocation being in a mov
instruction) but it verifies that the instruction
is a mov before rewriting it to lea.
Also makes typedefs global across files.
Fixes#1335.
Fixes#1345.
R=iant, r
CC=golang-dev
https://golang.org/cl/3650042
The recent linker changes broke NaCl support
a month ago, and there are no known users of it.
The NaCl code can always be recovered from the
repository history.
R=adg, r
CC=golang-dev
https://golang.org/cl/3671042
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
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
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
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
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
Load the entire archive file instead.
Reduces I/O by avoiding additional passes
through libraries to resolve symbols.
Go packages always need all the files anyway
(most often, all 1 of them).
R=ken2
CC=golang-dev
https://golang.org/cl/2613042
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
No multiple processes/locks, managed to compile
and run a hello.go (with print not fmt). Also test/sieve.go
seems to run until 439 and stops with a
'throw: all goroutines are asleep - deadlock!'
- just like runtime/tiny.
based on Russ's suggestions at:
http://groups.google.com/group/comp.os.plan9/browse_thread/thread/cfda8b82535d2d68/243777a597ec1612
Build instructions:
cd src/pkg/runtime
make clean && GOOS=plan9 make install
this will build and install the runtime.
When linking with 8l, you should pass -s to suppress symbol
generation in the a.out, otherwise the generated executable will not run.
This is runtime only, the porting of the toolchain has already
been done: http://code.google.com/p/go-plan9/source/browse
in the plan9-quanstro branch.
R=rsc
CC=golang-dev
https://golang.org/cl/2273041
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
The old code said
if(x) {
handle a
return
}
aa = *a
rewrite aa to make x true
recursivecall(&aa)
The new code says
params = copy out of a
if(!x) {
rewrite params to make x true
}
handle params
but it's hard to see that in the Rietveld diffs because
it gets confused by changes in indentation.
Avoiding the recursion makes other changes easier.
R=ken2
CC=golang-dev
https://golang.org/cl/2533041
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
The Plan 9 tools assume that long is 32 bits.
We converted all instances of long to int32 when
importing the code but missed the print formats.
Because int32 is always int on the compilers we use,
it is never correct to use %lux, %ld, etc. Convert to %ux, %d, etc.
(It matters because on 64-bit gcc, long is 64 bits,
so we were printing 32-bit quantities with 64-bit formats.)
R=ken2
CC=golang-dev
https://golang.org/cl/2491041
* Maintain Sym* list for text with individual
prog lists instead of using one huge list and
overloading p->pcond.
* Comment what each file is for.
* Move some output code from span.c to asm.c.
* Move profiling into prof.c, symbol table into symtab.c.
* Move mkfwd to ld/lib.c.
* Throw away dhog dynamic loading code.
* Throw away Alef become.
* Fix printing of WORD instructions in 5l -a.
Goal here is to be able to handle each piece of text or data
as a separate piece, both to make it easier to load the
occasional .o file and also to make it possible to split the
work across multiple threads.
R=ken2, r, ken3
CC=golang-dev
https://golang.org/cl/2335043
This is entirely adding and removing tabs.
It looks weird but will make the diffs for the
next change easier to read.
R=ken2
CC=golang-dev
https://golang.org/cl/2490041
Was also recording for .dynstrtab which made the
table run out of space and would have caused confusion
if the ELF code tried to refer to any of the strings.
R=r
CC=golang-dev
https://golang.org/cl/2288041
Returns R14 and R15 to the available register pool.
Plays more nicely with ELF ABI C code.
In particular, our signal handlers will no longer crash
when a signal arrives during execution of a cgo C call.
Fixes#720.
R=ken2, r
CC=golang-dev
https://golang.org/cl/1847051
The Makefile and cgo now rewrite / to _ when creating the path.
The .so for gosqlite.googlecode.com/hg/sqlite is named
cgo_gosqlite.googlecode.com_hg_sqlite.so, and then 6l and 8l
both include a default rpath of $GOROOT/pkg/$GOOS_$GOARCH.
This should make it easier to move binaries from one system
to another.
Fixes#857.
R=iant, r
CC=golang-dev
https://golang.org/cl/1700048
This avoids a crash when using cgo where glibc's malloc thinks
that it can use some of the memory following the symbol table.
This fails because the symbol table is mapped read-only, which
affects the whole page.
R=rsc
CC=golang-dev
https://golang.org/cl/1616042
Due to page boundary rounding, the header would have
been loaded as part of the text segment already, but this
change placates the "paxctl" tool on so-called hardened
Linux distributions (as if normal distributions weren't already
hard enough to use).
R=r
CC=golang-dev
https://golang.org/cl/954041
This permits more flexibility with cgo and swig in cases where
the program is run on a machine other than the one on which it
is built. Rather than storing the absolute path to the shared
library in the DT_NEEDED entry, we can store just the name,
and let the dynamic linker find it using DT_RUNPATH or the
LD_LIBRARY_PATH environment variable.
R=rsc
CC=golang-dev
https://golang.org/cl/223068
eliminates spurious multiple initialization errors.
give more information in the multiple init errors that remain.
Fixes#87.
R=r
CC=golang-dev
https://golang.org/cl/194052
5g/6g/8g: add import statements to export metadata, mapping package path to package name.
recognize "" as the path of the package in export metadata.
use "" as the path of the package in object symbol names.
5c/6c/8c, 5a/6a/8a: rewrite leading . to "". so that ·Sin means Sin in this package.
5l/6l/8l: rewrite "" in symbol names as object files are read.
gotest: handle new symbol names.
gopack: handle new import lines in export metadata.
Collectively, these changes eliminate the assumption of a global
name space in the object file formats. Higher level pieces such as
reflect and the computation of type hashes still depend on the
assumption; we're not done yet.
R=ken2, r, ken3
CC=golang-dev
https://golang.org/cl/186263
* switch to real dot (.) instead of center dot (·) everywhere in object files.
before it was half and half depending on where in the name it appeared.
* in 6c/6a/etc identifiers, · can still be used but turns into . immediately.
* in export metadata, replace package identifiers with quoted strings
(still package names, not paths).
R=ken2, r
CC=golang-dev
https://golang.org/cl/190076
the bash scripts and makefiles for building go didn't take into account
the fact $GOROOT / $GOBIN could both be directories containing whitespaces,
and was not possible to build it in such a situation.
this commit adjusts the various makefiles/scripts to make it aware of that
possibility, and now it builds successfully when using a path with whitespaces
as well.
Fixes#115.
R=rsc, dsymonds1
https://golang.org/cl/157067
because they are in package runtime.
another step to enforcing package boundaries.
R=r
DELTA=732 (114 added, 93 deleted, 525 changed)
OCL=35811
CL=35824
better mach binaries.
cgo working on darwin+linux amd64+386.
eliminated context switches - pi is 30x faster.
add libcgo to build.
on snow leopard:
- non-cgo binaries work; all tests pass.
- cgo binaries work on amd64 but not 386.
R=r
DELTA=2031 (1316 added, 626 deleted, 89 changed)
OCL=35264
CL=35304
add jmp to constant pc.
generate HLT for INT $3
do not insert NOPs between REP/REPN and subsequent instruction.
allow very long time for convergence.
R=ken
OCL=34879
CL=34879
- ELF header bits and addresses
- do not let instructions span 32-byte boundary
- align CALLs so return is to 32-byte boundary
- align indirect jump targets to 32-byte boundary
(only possible indirect jumps are function entries)
still to do:
- replace indirect jump, indirect call, and ret with
nacl-approved instruction sequences
- switch to GS segment for m-local storage
R=ken
OCL=34818
CL=34818
if first function in file was dead code, it was being
discarded along with the file name information for that file.
leave the functions in the master function list longer:
let xfol take the dead code out of the code list,
and let span skip the unreachable functions during output.
before
throw: sys·mapaccess1: key not in map
panic PC=0x2e7b20
throw+0x33 /Users/rsc/go/src/pkg/runtime/runtime.c:65
throw(0x5834f, 0x0)
sys·mapaccess1+0x73 /Users/rsc/go/src/pkg/runtime/hashmap.c:769
sys·mapaccess1(0x2b9bd0, 0x0)
gob·*Encoder·Encode+0x16b /Users/rsc/go/src/pkg/fmt/print.go:2926
gob·*Encoder·Encode(0x2bb440, 0x0, 0x558b0, 0x0, 0x2e4be0, ...)
main·walk+0x331 :1603
main·walk(0x33a480, 0x0)
main·walk+0x271 :1596
main·walk(0x300640, 0x0)
main·walk+0x271 :1596
main·walk(0x300520, 0x0)
main·walk+0x271 :1596
main·walk(0x300240, 0x0)
main·walk+0x271 :1596
main·walk(0x678f8, 0x0)
main·main+0x22 :1610
main·main()
after
throw: sys·mapaccess1: key not in map
panic PC=0x2e7b20
throw+0x33 /Users/rsc/go/src/pkg/runtime/runtime.c:65
throw(0x5834f, 0x0)
sys·mapaccess1+0x73 /Users/rsc/go/src/pkg/runtime/hashmap.c:769
sys·mapaccess1(0x2b9bd0, 0x0)
gob·*Encoder·Encode+0x16b /Users/rsc/go/src/pkg/gob/encoder.go:319
gob·*Encoder·Encode(0x2bb3c0, 0x0, 0x558b0, 0x0, 0x2e4be0, ...)
main·walk+0x331 /Users/rsc/dir.go:121
main·walk(0x2f6ab0, 0x0)
main·walk+0x271 /Users/rsc/dir.go:114
main·walk(0x301640, 0x0)
main·walk+0x271 /Users/rsc/dir.go:114
main·walk(0x301520, 0x0)
main·walk+0x271 /Users/rsc/dir.go:114
main·walk(0x301240, 0x0)
main·walk+0x271 /Users/rsc/dir.go:114
main·walk(0x678f8, 0x0)
main·main+0x22 /Users/rsc/dir.go:128
main·main()
mainstart+0xe /Users/rsc/go/src/pkg/runtime/amd64/asm.s:55
mainstart()
goexit /Users/rsc/go/src/pkg/runtime/proc.c:133
goexit()
R=r
DELTA=46 (20 added, 25 deleted, 1 changed)
OCL=34094
CL=34103
* use //ffi comments in package import data
to generate relocation entries and library loads.
* call initffi in rt0.s if present
R=r
DELTA=117 (91 added, 3 deleted, 23 changed)
OCL=33739
CL=33750
* remove now-unused D_SBIG (was for typestrings)
* rename elf64.[ch] to elf.[ch]
* pull in elf headers from FreeBSD instead of writing our own
* emit non-header ELF data in data section
* stub out a few more ELF sections needed for dynamic loading
R=r
DELTA=1928 (1237 added, 635 deleted, 56 changed)
OCL=33642
CL=33658
archive size +70%
binary size +30%
old
wreck.mtv=; ls -l /Users/rsc/bin/{godoc,gofmt}
-rwxr-xr-x 1 rsc eng 1487922 Aug 13 13:21 /Users/rsc/bin/godoc
-rwxr-xr-x 1 rsc eng 995995 Aug 13 13:21 /Users/rsc/bin/gofmt
wreck.mtv=; du -sh $GOROOT/pkg/
9.5M /home/rsc/go/pkg/
wreck.mtv=;
new
wreck.mtv=; ls -l /Users/rsc/bin/{godoc,gofmt}
-rwxr-xr-x 1 rsc eng 2014390 Aug 13 14:25 /Users/rsc/bin/godoc
-rwxr-xr-x 1 rsc eng 1268705 Aug 13 14:25 /Users/rsc/bin/gofmt
wreck.mtv=; du -sh $GOROOT/pkg
16M /home/rsc/go/pkg
wreck.mtv=;
R=ken
OCL=33217
CL=33220
hope this will work around Mac NFS bug
where writing to an 8.out that has crashed
recently sometimes wedges NFS.
R=r
DELTA=3 (3 added, 0 deleted, 0 changed)
OCL=32906
CL=32908