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

500 Commits

Author SHA1 Message Date
Carl Shapiro
47568c747d cmd/5a, cmd/5c, cmd/6a, cmd/6c, cmd/8a, cmd/8c, cmd/ld: update reference
Reference the 80386 compiler documentation now that the
documentation for the 68020 is offline.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7127053
2013-01-18 13:39:53 -08:00
Shenghou Ma
9ae7f34084 cmd/gc, cmd/ld: update doc.go for -race
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/7066052
2013-01-11 12:35:58 +08:00
Shenghou Ma
d5d4ee47ed cmd/5l: support -Z (zero stack frame at function entry)
also added appropriate docs to cmd/ld/doc.go
(largely copied from Russ's CL 6938073).

R=rsc
CC=golang-dev
https://golang.org/cl/7004049
2013-01-11 12:24:28 +08:00
Anthony Martin
74c03cb814 cmd/ld: fix incompatible type signatures on Plan 9
Changeset f483bfe81114 moved ELF generation to the architecture
independent code and in doing so added a Section* to the Sym
type and an Elf64_Shdr* to the Section type.

This caused the Plan 9 compilers to complain about incompatible
type signatures in the many files that reference the Sym type.

R=rsc, dave
CC=golang-dev
https://golang.org/cl/7057058
2013-01-09 15:05:22 -08:00
Russ Cox
a091d2e676 cmd/gc, cmd/ld: rename -b to -race
There's no b in race detector.
The new flag matches the one in the go command
(go test -race math).

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7072043
2013-01-06 22:47:39 -05:00
Russ Cox
cbbc6a102d cmd/5l, cmd/6l, cmd/8l, cmd/cc, cmd/gc: new flag parsing
This CL adds a flag parser that matches the semantics of Go's
package flag. It also changes the linkers and compilers to use
the new flag parser.

Command lines that used to work, like
        8c -FVw
        6c -Dfoo
        5g -I/foo/bar
now need to be split into separate arguments:
        8c -F -V -w
        6c -D foo
        5g -I /foo/bar
The new spacing will work with both old and new tools.

The new parser also allows = for arguments, as in
        6c -D=foo
        5g -I=/foo/bar
but that syntax will not work with the old tools.

In addition to matching standard Go binary flag parsing,
the new flag parser generates more detailed usage messages
and opens the door to long flag names.

The recently added gc flag -= has been renamed -complete.

R=remyoudompheng, daniel.morsing, minux.ma, iant
CC=golang-dev
https://golang.org/cl/7035043
2013-01-06 15:24:47 -05:00
Russ Cox
d37c572ad5 cmd/ld: move symtab, ELF generation to portable code
More cleanup in preparation for fixing issue 4069.

This CL replaces the three nearly identical copies of the
asmb ELF code with a single asmbelf function in elf.c.

In addition to the ELF code movement, remove the elfstr
array in favor of a simpler lookup, and identify sections by
name throughout instead of computing fragile indices.

The CL also replaces the three nearly identical copies of the
genasmsym code with a single genasmsym function in lib.c.

The ARM linker still compiles and generates binaries,
but I haven't tested the binaries. They may not work.

R=ken2
CC=golang-dev
https://golang.org/cl/7062047
2013-01-06 14:32:45 -05:00
Russ Cox
4e2aa9bff0 cmd/ld: use native-endian symbol values in symbol table
The Plan 9 symbol table format defines big-endian symbol values
for portability, but we want to be able to generate an ELF object file
and let the host linker link it, as part of the solution to issue 4069.
The symbol table itself, since it is loaded into memory at run time,
must be filled in by the final host linker, using relocation directives
to set the symbol values. On a little-endian machine, the linker will
only fill in little-endian values during relocation, so we are forced
to use little-endian symbol values.

To preserve most of the original portability of the symbol table
format, we make the table itself say whether it uses big- or
little-endian values. If the table begins with the magic sequence
        fe ff ff ff 00 00
then the actual table begins after those six bytes and contains
little-endian symbol values. Otherwise, the table is in the original
format and contains big-endian symbol values. The magic sequence
looks like an "end of table" entry (the fifth byte is zero), so legacy
readers will see a little-endian table as an empty table.

All the gc architectures are little-endian today, so the practical
effect of this CL is to make all the generated tables little-endian,
but if a big-endian system comes along, ld will not generate
the magic sequence, and the various readers will fall back to the
original big-endian interpretation.

R=ken2
CC=golang-dev
https://golang.org/cl/7066043
2013-01-04 17:03:57 -05:00
Lucio De Re
62dfa9c47d cmd/5g, cmd/5l, cmd/ld: Small adjustments for the Plan 9 native tools
A few USED(xxx) additions and a couple of deletions of variable
initialisations that go unused.  One questionable correction,
mirrored in 8l/asm.c, where the result of invocation of a function
shouldn't be used.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6736054
2013-01-04 11:02:49 -05:00
Dave Cheney
6535eb3a6d cmd/ld: fix valgrind warning in strnput
Fixes #4592.

Thanks to minux for the suggestion.

R=minux.ma, iant
CC=golang-dev
https://golang.org/cl/7017048
2012-12-28 15:32:24 +11:00
Russ Cox
9d2b0e86c8 cmd/ld: skip 0-length write in cwrite
The 0-length part is fine, but some callers that write 0 bytes
also pass nil as the data pointer, and the Plan 9 kernel kills the
process with 'invalid address in sys call' in that case.

R=ken2
CC=golang-dev
https://golang.org/cl/6862051
2012-12-06 00:00:20 -05:00
Shenghou Ma
af375cde20 libmach, cmd/cc, cmd/cov, cmd/ld, cmd/prof: check malloc return value
Update #4415.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6856080
2012-11-27 03:05:46 +08:00
Shenghou Ma
3513d84068 runtime/cgo: fix compilation on Windows with CFLAGS -Wall -Werror
also fix one out-of-date comment in cmd/ld/pe.c as well.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6843061
2012-11-18 02:06:08 +08:00
Russ Cox
1120982590 reflect: add ArrayOf, ChanOf, MapOf, SliceOf
In order to add these, we need to be able to find references
to such types that already exist in the binary. To do that, introduce
a new linker section holding a list of the types corresponding to
arrays, chans, maps, and slices.

To offset the storage cost of this list, and to simplify the code,
remove the interface{} header from the representation of a
runtime type. It was used in early versions of the code but was
made obsolete by the kind field: a switch on kind is more efficient
than a type switch.

In the godoc binary, removing the interface{} header cuts two
words from each of about 10,000 types. Adding back the list of pointers
to array, chan, map, and slice types reintroduces one word for
each of about 500 types. On a 64-bit machine, then, this CL *removes*
a net 156 kB of read-only data from the binary.

This CL does not include the needed support for precise garbage
collection. I have created issue 4375 to track that.

This CL also does not set the 'algorithm' - specifically the equality
and copy functions - for a new array correctly, so I have unexported
ArrayOf for now. That is also part of issue 4375.

Fixes #2339.

R=r, remyoudompheng, mirtchovski, iant
CC=golang-dev
https://golang.org/cl/6572043
2012-11-13 13:06:29 -05:00
Shenghou Ma
31f8b07e55 runtime/cgo, go/build: cgo support for FreeBSD/ARM
This is the last CL for FreeBSD/ARM support.
Also update cmd/ld/doc.go for 5l support of -Hfreebsd.

R=rsc
CC=golang-dev
https://golang.org/cl/6650051
2012-11-03 02:22:37 +08:00
Russ Cox
3d40062c68 cmd/gc, cmd/ld: struct field tracking
This is an experiment in static analysis of Go programs
to understand which struct fields a program might use.
It is not part of the Go language specification, it must
be enabled explicitly when building the toolchain,
and it may be removed at any time.

After building the toolchain with GOEXPERIMENT=fieldtrack,
a specific field can be marked for tracking by including
`go:"track"` in the field tag:

        package pkg

        type T struct {
                F int `go:"track"`
                G int // untracked
        }

To simplify usage, only named struct types can have
tracked fields, and only exported fields can be tracked.

The implementation works by making each function begin
with a sequence of no-op USEFIELD instructions declaring
which tracked fields are accessed by a specific function.
After the linker's dead code elimination removes unused
functions, the fields referred to by the remaining
USEFIELD instructions are the ones reported as used by
the binary.

The -k option to the linker specifies the fully qualified
symbol name (such as my/pkg.list) of a string variable that
should be initialized with the field tracking information
for the program. The field tracking string is a sequence
of lines, each terminated by a \n and describing a single
tracked field referred to by the program. Each line is made
up of one or more tab-separated fields. The first field is
the name of the tracked field, fully qualified, as in
"my/pkg.T.F". Subsequent fields give a shortest path of
reverse references from that field to a global variable or
function, corresponding to one way in which the program
might reach that field.

A common source of false positives in field tracking is
types with large method sets, because a reference to the
type descriptor carries with it references to all methods.
To address this problem, the CL also introduces a comment
annotation

        //go:nointerface

that marks an upcoming method declaration as unavailable
for use in satisfying interfaces, both statically and
dynamically. Such a method is also invisible to package
reflect.

Again, all of this is disabled by default. It only turns on
if you have GOEXPERIMENT=fieldtrack set during make.bash.

R=iant, ken
CC=golang-dev
https://golang.org/cl/6749064
2012-11-02 00:17:21 -04:00
Shenghou Ma
78a6f75241 cmd/ld: handle weak symbols
compiler_rt introduces a weak and hidden symbol compilerrt_abort_impl
into our pre-linked _all.o object, we have to handle it.

Fixes #4273.

R=iant, rsc, r
CC=golang-dev
https://golang.org/cl/6783050
2012-10-30 23:58:43 +08:00
Russ Cox
80dbe74360 cmd/gc, cmd/ld: use go.weak instead of weak as the weak symbol prefix
Also defend our symbol prefixes (now just "go" and "type")
from use as import paths.

Fixes #4257.

R=ken2
CC=golang-dev
https://golang.org/cl/6744072
2012-10-23 11:16:08 -04:00
Ian Lance Taylor
32316bba5b cmd/ld: add -B option to set build ID
Background on build ID:
http://fedoraproject.org/wiki/RolandMcGrath/BuildID

R=rsc
CC=golang-dev
https://golang.org/cl/6625072
2012-10-09 15:29:43 -07:00
Shenghou Ma
fa563ae82e cmd/ld, cmd/6l, cmd/8l: sort exported dynamic symbols for Darwin
Also corrected cmd/8l's .dynsym handling (differentiate between exported symbols and imported symbols)

        Fixes #4029.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6620075
2012-10-10 00:55:48 +08:00
Russ Cox
f76f120324 cmd/ld: use 64-bit alignment for large data and bss objects
Check for specific, important misalignment in garbage collector.
Not a complete fix for issue 599 but an important workaround.

Update #599.

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/6641049
2012-10-09 12:50:06 -04:00
Shenghou Ma
65b782e951 cmd/ld, cmd/5l: support R_ARM_PC24 and R_ARM_JUMP24, fix R_ARM_CALL
1. R_ARM_CALL can also be used to call a PLT entry
2. add support for R_ARM_PC24 and R_ARM_JUMP24
3. refactor, remove D_PLT32 in favor of D_CALL

Fixes #4006.

R=rsc, dave
CC=fullung, golang-dev
https://golang.org/cl/6622057
2012-10-08 04:20:17 +08:00
Shenghou Ma
5490814c30 cmd/go, cmd/ld: fix libgcc order and add __image_base__ symbol for windows
Fixes #4063.

R=alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/6543066
2012-09-26 22:34:25 +08:00
Russ Cox
0bf46d0cf3 cmd/ld: prepare for 64-bit ints
Use explicit IntSize constant instead of 4.

This CL does not change the meaning of int, but it should make
the eventual change of the meaning of int on amd64 a bit
smoother.

Update #2188.

R=ken, dave
CC=golang-dev
https://golang.org/cl/6554076
2012-09-24 14:59:09 -04:00
Joel Sing
31758b2c1a cmd/{ld,5l,6l,8l}: add support for OpenBSD ELF signatures
OpenBSD now requires ELF binaries to have a PT_NOTE that identifies
it as an OpenBSD binary. Refactor the existing NetBSD ELF signature
code and implement support for OpenBSD ELF signatures.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6489131
2012-09-21 12:51:39 +10:00
Lucio De Re
091388d8e9 cmd/ld: remove unused assignment
The calculation of datsize is redundant.

R=golang-dev, seed, rsc
CC=golang-dev
https://golang.org/cl/6503122
2012-09-20 14:58:33 -04:00
Shenghou Ma
4d7c81bc67 cmd/ld: consistent binary for cgo programs
We use pkg path instead of file name (which contains $WORK) in section symbols names.

R=golang-dev, fullung, rsc, iant
CC=golang-dev
https://golang.org/cl/6445085
2012-09-20 00:18:41 +08:00
Dmitriy Vyukov
cc8cfefd8a race: linker changes
This is the second part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044
This change makes the linker emit dependency on runtime/race package when supplied with -b flag.

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6488074
2012-09-19 01:05:25 +04:00
Lucio De Re
b29ed23ab5 build: fix various 'set and not used' for Plan 9
R=dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6501134
2012-09-17 17:25:26 -04:00
Jan Ziak
032e5bfb30 ld: add .gcdata and .gcbss sections
R=rsc
CC=golang-dev
https://golang.org/cl/6281048
2012-09-13 15:59:34 -04:00
Russ Cox
6ee91ced92 cmd/pack: rename __.SYMDEF to __.GOSYMDEF
This fixes a problem with ELF tools thinking they know the
format of the symbol table, as we do not use any of the
standard formats for that table.

This change will probably annoy the Plan 9 users, but I
believe there are other incompatibilities already that mean
they have to use a Go-specific nm.

Fixes #3473.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6500117
2012-09-13 10:26:21 -04:00
Shenghou Ma
c5444a8937 cmd/ld: support zero-filled section for Mach-O files
R=golang-dev, r, dave, rsc
CC=golang-dev
https://golang.org/cl/6492069
2012-09-02 04:50:58 +08:00
Shenghou Ma
e607380ff6 cmd/ld: handle a special case of scattered relocation 2/1 on Darwin/386
Fixes #1635.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/6496043
2012-08-29 23:42:05 +08:00
Shenghou Ma
1cf27acfed cmd/ld: set ELF header flags for our Linux/ARM binary
To make it more compliant.
This won't affect the behavior of running on OABI-only kernels.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6475044
2012-08-23 14:33:41 +08:00
Shenghou Ma
b1532344ef cmd/ld: skip R_*_NONE relocations, fix Linux/386 build again
The last fix was wrong w.r.t C's operator precedence,
and it also failed to really skip the NONE relocation.

The offending R_386_NONE relocation is a absolute
relocation in section .eh_frame.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/6463058
2012-08-21 00:34:06 +08:00
Shenghou Ma
93fac8859c cmd/ld: explicitly ignore R_*_NONE relocation to fix build
I don't know why this relocation is used.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6464070
2012-08-17 09:11:58 +08:00
Russ Cox
3f34248a77 cmd/ld: add PT_PAX_FLAGS ELF header
PAX systems are Linux systems that are more paranoid about memory permissions.
These flags tell them to relax when running Go binaries.

Fixes #47.

R=iant
CC=golang-dev
https://golang.org/cl/6326054
2012-08-03 15:27:35 -04:00
Shenghou Ma
9de61e7c8c cmd/5l, cmd/ld: add support for R_ARM_GOT_PREL
Android NDK's gcc 4.6 generates this relocation for runtime/cgo.

R=rsc
CC=golang-dev
https://golang.org/cl/6450056
2012-07-30 18:48:00 -04:00
Jan Ziak
65e61d5770 runtime: add (unused for now) gc field to type information
R=rsc
CC=golang-dev
https://golang.org/cl/6255074
2012-06-02 14:02:44 -04:00
Russ Cox
8820ab5da9 cmd/ld: align function entry on arch-specific boundary
16 seems pretty standard on x86 for function entry.
I don't know if ARM would benefit, so I used just 4
(single instruction alignment).

This has a minor absolute effect on the current timings.
The main hope is that it will make them more consistent from
run to run.

benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    4222117400   4140739800   -1.93%
BenchmarkFannkuch11      3462631800   3259914400   -5.85%
BenchmarkGobDecode         20887622     20620222   -1.28%
BenchmarkGobEncode          9548772      9384886   -1.72%
BenchmarkGzip                151687       150333   -0.89%
BenchmarkGunzip                8742         8741   -0.01%
BenchmarkJSONEncode        62730560     65210990   +3.95%
BenchmarkJSONDecode       252569180    249394860   -1.26%
BenchmarkMandelbrot200      5267599      5273394   +0.11%
BenchmarkRevcomp25M       980813500    996013800   +1.55%
BenchmarkTemplate         361259100    360620840   -0.18%

R=ken2
CC=golang-dev
https://golang.org/cl/6244066
2012-05-30 16:26:38 -04:00
Joel Sing
586b6dfa46 cmd/ld: increase number of ELF sections
On NetBSD a cgo enabled binary has more than 32 sections - bump NSECTS
so that we can actually link them successfully.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6261052
2012-05-31 03:06:38 +10:00
Akshat Kumar
154c84cdac cmd/6l: Fixes for 64-bit Plan 9
Plan 9 versions for amd64 have 2 megabyte pages.
This also fixes the logic for 32-bit vs 64-bit Plan 9,
making 64-bit the default, and adds logic to generate
a symbols table.

R=golang-dev, rsc, rminnich, ality, 0intro
CC=golang-dev, john
https://golang.org/cl/6218046
2012-05-29 12:32:42 -04:00
Shenghou Ma
e0b0f62d96 cmd/ld: fix Linux/ARM build
CL 5823055 removed a line introduced in Linux/ARM cgo support.
        Because readsym() now returns nil for "$a", "$d" mapping symbols,
        no matter the settings of `needSym', we still have to guard against
        them in ldelf().

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6220073
2012-05-23 11:36:24 +08:00
Shenghou Ma
576d648b2a cmd/ld, cmd/6l, cmd/8l, cmd/5l: fix hidden/local symbol import for ELF systems
Introduce a newsym() to cmd/lib.c to add a symbol but don't add
them to hash table.
   Introduce a new bit flag SHIDDEN and bit mask SMASK to handle hidden
and/or local symbols in ELF symbol tables. Though we still need to order
the symbol table entries correctly.
   Fix for issue 3261 comment #9.
   For CL 5822049.

R=iant, rsc
CC=golang-dev
https://golang.org/cl/5823055
2012-05-23 02:32:27 +08:00
Shenghou Ma
1c4b77a7c8 cmd/ld: take section symbols' value into account for PE
ld -r could generate multiple section symbols for the same section,
but with different values, we have to take that into account.
    Fixes #3322.
    Part of issue 3261.
    For CL 5822049.

R=golang-dev, iant, rsc, iant
CC=golang-dev
https://golang.org/cl/5823059
2012-05-23 02:27:44 +08:00
Shenghou Ma
dac4c3eee9 cmd/cgo, cmd/cc, cmd/ld: detect dynamic linker automatically
Some newer Linux distributions (Ubuntu ARM at least) use a new multiarch
directory organization, where dynamic linker is no longer in the hardcoded
path in our linker.
For example, Ubuntu 12.04 ARM hardfloat places its dynamic linker at
/lib/arm-linux-gnueabihf/ld-linux.so.3

Ref: http://lackof.org/taggart/hacking/multiarch/

Also, to support Debian GNU/kFreeBSD as a FreeBSD variant, we need this capability, so it's part of issue 3533.

This CL add a new pragma (#pragma dynlinker "path") to cc.

R=iant, rsc
CC=golang-dev
https://golang.org/cl/6086043
2012-05-05 01:54:16 +08:00
Shenghou Ma
452a9e452b cmd/5l, cmd/ld: dynamic linking library support
Part 1 of CL 5601044 (cgo: Linux/ARM support)
        Limitation: doesn't support thumb library yet.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/5991065
2012-05-04 18:14:26 +08:00
Shenghou Ma
736ff448de doc: various update to command documents
1. consistent usage section (go tool xxx)
        2. reformat cmd/ld document with minor correction
           document which -H flags are valid on which ld
           document -d flag can't be used on Windows.
           document -Hwindowsgui

R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/5782043
2012-03-09 01:31:09 +08:00
Shenghou Ma
a142ed99d5 fix build for FreeBSD/amd64
R=rsc, golang-dev, iant
CC=golang-dev
https://golang.org/cl/5732043
2012-03-03 04:47:42 +08:00
Shenghou Ma
5aea33742a ld: allow more -L options
Dynamically allocate the libdir array, so we won't need to bother it again.
        Enhances CL 5727043.

R=rsc
CC=golang-dev
https://golang.org/cl/5731043
2012-03-03 04:14:31 +08:00
Russ Cox
15d8b05f0c ld: fix alignment of rodata section
We were not aligning the code size,
so read-only data, which follows in the same
segment, could be arbitrarily misaligned.

Fixes #2506.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5693055
2012-02-23 23:01:36 -05:00
Russ Cox
c2cd0d09c2 ld: get symbol table letters right
Have to assign them before we create the symbol table.
ARM debugging.

TBR=r
CC=golang-dev
https://golang.org/cl/5689067
2012-02-22 01:30:04 -05:00
Russ Cox
5bcad92f07 ld: add NOPTRBSS for large, pointer-free uninitialized data
cc: add #pragma textflag to set it
runtime: mark mheap to go into noptr-bss.
        remove special case in garbage collector

Remove the ARM from.flag field created by CL 5687044.
The DUPOK flag was already in p->reg, so keep using that.

Otherwise test/nilptr.go creates a very large binary.
Should fix the arm build.
Diagnosed by minux.ma; replacement for CL 5690044.

R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/5686060
2012-02-21 22:08:42 -05:00
Russ Cox
4e3f8e915f gc, ld: tag data as no-pointers and allocate in separate section
The garbage collector can avoid scanning this section, with
reduces collection time as well as the number of false positives.
Helps a little bit with issue 909, but certainly does not solve it.

R=ken2
CC=golang-dev
https://golang.org/cl/5671099
2012-02-19 03:19:52 -05:00
Russ Cox
6a75ece01c runtime: delete Type and implementations (use reflect instead)
unsafe: delete Typeof, Reflect, Unreflect, New, NewArray

Part of issue 2955 and issue 2968.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5650069
2012-02-12 23:26:20 -05:00
Russ Cox
e3755434b8 5l, 6l, 8l: implement -X flag
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5643050
2012-02-07 16:46:33 -05:00
Wei Guangjing
f8e9bbe475 cmd/ld: fix gdbscript
R=golang-dev, lvd
CC=golang-dev
https://golang.org/cl/5601058
2012-01-31 10:32:24 -05:00
Shenghou Ma
916eea04f8 5l, 6l, 8l, ld: remove memory leaks
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5569085
2012-01-29 12:46:26 -05:00
Mikkel Krautz
280d85a80b ld: fix Mach-O code signing for non-cgo binaries
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5561060
2012-01-23 09:42:09 -05:00
Joel Sing
5842f7e46a 5l/6l/8l: add support for netbsd signature note section
R=m4dh4tt3r, jsing, rsc
CC=golang-dev
https://golang.org/cl/5493068
2011-12-20 12:25:06 +11:00
Alex Brainman
2da651f115 ld: allow for IMAGE_REL_AMD64_ADDR32NB relocation type
enable cgo again on windows/amd64

R=rsc, vcc.163
CC=golang-dev
https://golang.org/cl/5488074
2011-12-16 10:32:14 +11:00
Russ Cox
196b663075 gc: implement == on structs and arrays
To allow these types as map keys, we must fill in
equal and hash functions in their algorithm tables.
Structs or arrays that are "just memory", like [2]int,
can and do continue to use the AMEM algorithm.
Structs or arrays that contain special values like
strings or interface values use generated functions
for both equal and hash.

The runtime helper func runtime.equal(t, x, y) bool handles
the general equality case for x == y and calls out to
the equal implementation in the algorithm table.

For short values (<= 4 struct fields or array elements),
the sequence of elementwise comparisons is inlined
instead of calling runtime.equal.

R=ken, mpimenov
CC=golang-dev
https://golang.org/cl/5451105
2011-12-12 22:22:09 -05:00
Christopher Nielsen
420fe22921 ld/6l/8l: First pass at changes to the linker to support NetBSD binaries.
This will not currently create valid NetBSD binaries because NetBSD requires
an ELF note section to run, otherwise the kernel will throw ENOEXEC. I was
unable to determine an elegant way to add the section, so I am submitting
what I have.

References:
http://www.netbsd.org/docs/kernel/elf-notes.html
http://mail-index.netbsd.org/netbsd-bugs/2001/08/03/0012.html

R=rsc
CC=golang-dev
https://golang.org/cl/5472049
2011-12-12 15:42:11 -05:00
Scott Lawrence
a2ba34d374 ld: fix memory leaks
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5434068
2011-12-07 11:50:39 -05:00
Dmitriy Vyukov
428062da4e ld: increase default stack size on Windows for cgo
Fixes #2437.

R=rsc, hectorchu, mattn.jp, alex.brainman, jdpoirier, snaury, n13m3y3r
CC=golang-dev
https://golang.org/cl/5371049
2011-12-07 16:53:17 +03:00
Russ Cox
b9ccd077dc runtime: prep for type-specific algorithms
Equality on structs will require arbitrary code for type equality,
so change algorithm in type data from uint8 to table pointer.
In the process, trim top-level map structure from
104/80 bytes (64-bit/32-bit) to 24/12.

Equality on structs will require being able to call code generated
by the Go compiler, and C code has no way to access Go return
values, so change the hash and equal algorithm functions to take
a pointer to a result instead of returning the result.

R=ken
CC=golang-dev
https://golang.org/cl/5453043
2011-12-05 09:40:22 -05:00
Ian Lance Taylor
bf43161c00 ld: align ELF data sections
fixes #2506

R=rsc, iant
CC=golang-dev
https://golang.org/cl/5440066
2011-11-30 13:24:16 -08:00
Wei Guangjing
3199a6ca8d ld: fix .bss for ldpe.
Fixes #2409.

R=mattn.jp, rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/5334046
2011-11-11 14:40:24 -05:00
Russ Cox
80bce97e45 gc, ld: sync pathtoprefix + add comments
R=lvd, lvd
CC=golang-dev
https://golang.org/cl/5332051
2011-11-03 12:44:51 -04:00
Russ Cox
7b04471dfa gopack: change archive file name length back to 16
This CL grew the archive file name length from 16 to 64:

        changeset:   909:58574851d792
        user:        Russ Cox <rsc@golang.org>
        date:        Mon Oct 20 13:53:56 2008 -0700

Back then, every x.go file in a package became an x.6 file
in the archive.  It was important to be able to allow the
use of long Go source file names, hence the increase in size.

Today, all Go source files compile into a single _go_.6 file
regardless of their names, so the archive file name length
no longer needs to be long.  The longer name causes some
problems on Plan 9, where the native archive format is the
same but with 16-byte names, so revert back to 16.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5333050
2011-11-01 00:29:16 -04:00
Russ Cox
6ed3fa6553 gc: introduce rune
R=ken, r
CC=golang-dev
https://golang.org/cl/5293046
2011-10-25 22:19:39 -07:00
Mikkel Krautz
78ad19f214 ld: modify macho linkedit segment to enable OS X code signing
Move string table to the end of the __LINKEDIT segment.

This change allows Apple's codesign(1) utility to successfully sign
Go binaries, as long as they don't contain DWARF data (-w flag to
8l/6l).  This is because codesign(1) expects the string table to be
the last part of the file.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5271050
2011-10-18 16:31:03 -04:00
Mikkel Krautz
4566868b41 6l, 8l: emit macho dwarf info before linkedit section
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5272050
2011-10-18 15:58:10 -04:00
Mikkel Krautz
c9bf048337 ld: bump pe linker version to 3.0 to allow code signing
The Windows signtool.exe thinks our binaries are 'invalid
Win32 programs' unless the PE linker version field is 3.0
or greater.

This minor change makes it possible to successfully sign
gc-built binaries on Windows.

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/5268045
2011-10-18 15:31:55 +11:00
Jaroslavas Počepko
ff866c4ca3 ld: Fixes issue 1899 ("cannot create 8.out.exe")
http://code.google.com/p/go/issues/detail?id=1899

R=rsc, alex.brainman, bsiegert, hectorchu, bradfitz
CC=golang-dev
https://golang.org/cl/4978047
2011-10-14 20:37:07 +01:00
Wei Guangjing
e7042418c5 cgo: support for mingw-w64 4.5.1 and newer
R=rsc, jp, hectorchu
CC=golang-dev
https://golang.org/cl/4962051
2011-10-06 07:22:48 +01:00
Russ Cox
e7e5c5adb3 runtime: fix map memory leak
The map implementation was using the C idiom of using
a pointer just past the end of its table as a limit pointer.
Unfortunately, the garbage collector sees that pointer as
pointing at the block adjacent to the map table, pinning
in memory a block that would otherwise be freed.

Fix by making limit pointer point at last valid entry, not
just past it.

Reviewed by Mike Burrows.

R=golang-dev, bradfitz, lvd, r
CC=golang-dev
https://golang.org/cl/5158045
2011-10-01 13:00:53 -04:00
Luuk van Dijk
ac1b9545e3 ld: grow dwarf includestack on demand.
Fixes #2241
while not breaking issue 1878 again.

R=rsc
CC=golang-dev
https://golang.org/cl/4988048
2011-09-09 15:08:57 +02:00
Hector Chu
9b011500c0 runtime: implement exception handling on windows/amd64
Fixes #2194.

R=rsc, alex.brainman, vcc.163, jp
CC=golang-dev
https://golang.org/cl/4977044
2011-09-03 18:27:16 +10:00
Russ Cox
4304de6e0c runtime: make arm work on Ubuntu Natty qemu
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4963050
2011-08-31 07:02:46 -04:00
Mateusz Czapliński
eae0a48cf5 libmach: support reading symbols from Windows .exe for nm
Fixes #979.

R=rsc, alex.brainman
CC=golang-dev, vcc.163
https://golang.org/cl/4894051
2011-08-29 14:25:43 -04:00
Yuval Pavel Zholkover
c20a338c2f runtime, syscall: use the vdso page on linux x86 for faster syscalls instead of int $0x80.
8l: fix handling CALL $(constant) code generated by 8a.
8a,8l: add indirect call instruction: CALL *data(SB).

R=rsc, iant
CC=golang-dev
https://golang.org/cl/4817054
2011-08-29 10:36:06 -04:00
Lucio De Re
45407bd559 ld: handle Plan 9 ar format
The Go version has 64 character long section names; originally,
in Plan 9, the limit was 16.  To provide compatibility, this
change allows the input length to be either the target length
or the earlier option.	The section name is extended with spaces
where required.

This has been tested to work without regressions in the
Go environment, testing the older alternative has not been
possible yet.

R=rsc
CC=golang-dev
https://golang.org/cl/4650071
2011-08-22 23:24:38 -04:00
Russ Cox
3554325937 ld: remove duplicate bss definitions
The EXTERN lines in elf.h already define these.
That's not a problem for most C compilers, but
apparently it is for some copies of the OS X linker.

Fixes #2167.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/4936044
2011-08-22 23:23:57 -04:00
Lucio De Re
93ecb5bb1b ld: make addaddrplus4 static
R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/4835043
2011-08-16 14:22:02 -04:00
Wei Guangjing
1ac7a69701 ld: add one empty symbol into pe to make dumpbin works.
Fixes #2139.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/4838056
2011-08-10 11:09:06 +10:00
David Symonds
11e254e62c ld: fail linking if the top-level package is not main.
This makes {5,6,8}l conform to the spec more tightly.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4826063
2011-08-02 07:45:04 -04:00
Lucio De Re
05f734c8b4 cmd/ld/pe.c: Corrected mismatched print formats and variables.
R=golang-dev, alex.brainman
CC=golang-dev, rsc
https://golang.org/cl/4839041
2011-08-01 11:12:50 +10:00
Joel Sing
ffa14e849c 6l: OpenBSD support
Add linker support for OpenBSD ELF-64.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4815066
2011-07-29 13:47:41 -04:00
Alex Brainman
fa249cae38 ld: remove cseekend and redo pe writing
Simplify code and add more checks.

Fixes #2105.

R=rsc
CC=golang-dev
https://golang.org/cl/4794060
2011-07-28 14:30:52 +10:00
Lucio De Re
75c918c1ae ld: fix build on Plan 9
ld/data.c:
. Format specifier with corresponding cast to cater for all
  architectures (llux and vlong).

ld/ldelf.c:
ld/ldmacho.c:
. Missing "pn" argument in diag() calls.

ld/ldpe.c:
. Dropped "sym->sectnum" in diag() call.
. Typo in a comment.

ld/lib.h:
. Added varargck pragma for "O".

R=rsc
CC=golang-dev
https://golang.org/cl/4749042
2011-07-25 13:45:50 -04:00
Wei Guangjing
0871af25aa ld: don't skip first 2 symbols in ldpe.
some object files don't has file name symbol.

R=golang-dev, lucio.dere, rsc
CC=golang-dev
https://golang.org/cl/4814051
2011-07-25 12:25:44 -04:00
Wei Guangjing
7ce1a4bdc0 ld: fixes .bss for ldpe
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4794056
2011-07-23 12:21:13 -04:00
Robert Griesemer
3ddaa95d71 fix build: clean up file end in an attempt to fix build
R=r, iant
CC=golang-dev
https://golang.org/cl/4809050
2011-07-22 22:45:14 -07:00
Wei Guangjing
4e5e12e305 ld: fixes ldpe link with SXREF global values.
R=golang-dev, mattn.jp, rsc
CC=golang-dev
https://golang.org/cl/4794052
2011-07-22 21:21:08 -04:00
Russ Cox
b9b204d55d ld: detect all import cycles
Fixes #2052.

R=r
CC=golang-dev
https://golang.org/cl/4812053
2011-07-22 21:18:03 -04:00
Dmitriy Vyukov
6b2ec06587 runtime: faster select
Make selectsend() accept pointer to the element,
it makes it possible to make Scase fixed-size
and allocate/free Select, all Scase's and all SudoG at once.
As a consequence SudoG freelist die out.

benchmark                       old,ns/op  new,ns/op
BenchmarkSelectUncontended	     1080        558
BenchmarkSelectUncontended-2	      675        264
BenchmarkSelectUncontended-4	      459        205
BenchmarkSelectContended	     1086        560
BenchmarkSelectContended-2	     1775       1672
BenchmarkSelectContended-4	     2668       2149
(on Intel Q6600, 4 cores, 2.4GHz)

benchmark                       old ns/op    new ns/op    delta
BenchmarkSelectUncontended         517.00       326.00  -36.94%
BenchmarkSelectUncontended-2       281.00       166.00  -40.93%
BenchmarkSelectUncontended-4       250.00        83.10  -66.76%
BenchmarkSelectUncontended-8       107.00        47.40  -55.70%
BenchmarkSelectUncontended-16       67.80        41.30  -39.09%
BenchmarkSelectContended           513.00       325.00  -36.65%
BenchmarkSelectContended-2         699.00       628.00  -10.16%
BenchmarkSelectContended-4        1085.00      1092.00   +0.65%
BenchmarkSelectContended-8        3253.00      2477.00  -23.85%
BenchmarkSelectContended-16       5313.00      5116.00   -3.71%
(on Intel E5620, 8 HT cores, 2.4 GHz)

R=rsc, ken
CC=golang-dev
https://golang.org/cl/4811041
2011-07-21 13:57:13 -04:00
Gustavo Niemeyer
14eba969d8 ld: fix freebsd build reverting .interp move
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4794046
2011-07-21 03:48:56 -03:00
Gustavo Niemeyer
ba2e3af177 ld: remove overlap of ELF sections on dynamic binaries
The dynamic ELF sections were pointing to the proper data,
but that data was already owned by the rodata and text sections.
Some ELF references explicitly prohibit multiple sections from
owning the same data, and strip behaves accordingly.

The data for these sections was moved out and their ranges are
now owned by their respective sections.  This change makes strip
happy both with and without -s being provided at link time.

A test was added in debug/elf to ensure there are no regressions
on this area in the future.

Fixes #1242.
Fixes #2022.

NOTE: Tested on Linux amd64/386/arm only.

R=rsc
CC=golang-dev
https://golang.org/cl/4808043
2011-07-20 12:47:02 -03:00
Wei Guangjing
9f636598ba cgo: windows amd64 port
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4725041
2011-07-19 10:47:33 -04:00
Russ Cox
caa5647408 ld: allow seek within write buffer
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-07-18 12:04:09 -04:00
Brad Fitzpatrick
dcdaeebdfb docs: fix wrong it's -> its
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/4702046
2011-07-13 10:54:51 -07:00
Gustavo Niemeyer
cf143e9dbf ld: fix ELF strip by removing overlap of sections
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-28 22:28:30 +01:00
Anthony Martin
10d0dffd76 ld: elide the Go symbol table when using -s
R=rsc, n13m3y3r, gustavo
CC=golang-dev
https://golang.org/cl/4661050
2011-06-27 14:39:38 -04:00
Gustavo Niemeyer
89d334ffe1 ld: don't attempt to build dynamic sections unnecessarily
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-22 15:12:22 -04:00
Lucio De Re
10b5519d3a 8l: more fixes for Plan 9
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-21 12:14:32 -04:00
Robert Hencke
b88e669a8f nacl, tiny: remove vestiges
R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/4635053
2011-06-21 12:02:40 -04:00
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
Luuk van Dijk
7400be87d8 runtime: generate Go defs for C types.
R=rsc, mattn
CC=golang-dev
https://golang.org/cl/4047047
2011-01-31 12:27:28 +01:00
Alex Brainman
d08df51366 8l/6l: pe fixes
- fixed length of amd64 .data pe section
  (don't need to include non-initialised data)

- use correct oh/oh64 variable when updating
  data directory in addexports

- simplify and cleanup

R=vcc, rsc
CC=golang-dev
https://golang.org/cl/4106044
2011-01-29 23:13:40 +11:00
Wei Guangjing
a3120f67ca 8l: add PE dynexport
R=rsc, brainman, mattn
CC=golang-dev
https://golang.org/cl/4022043
2011-01-27 08:26:31 -05:00
Wei Guangjing
354219951e 8l: fix ldpe sym name length == 8 strdup incorrect.
R=rsc
CC=golang-dev
https://golang.org/cl/4102043
2011-01-27 08:26:28 -05:00
Luuk van Dijk
2aa6cf3e7e [68]l: more robust decoding of reflection type info in generating dwarf.
R=rsc
CC=golang-dev, golang-dev
https://golang.org/cl/4106041
2011-01-24 20:59:39 +01:00
Wei Guangjing
f1751e7de5 8l: emit DWARF in Windows PE.
R=rsc, lvd, brainman, Joe Poirier
CC=golang-dev
https://golang.org/cl/2124041
2011-01-20 11:28:30 -05:00
Wei Guangjing
1aa2d88739 cgo: windows/386 port
R=rsc, peterGo, brainman
CC=golang-dev
https://golang.org/cl/3733046
2011-01-20 10:22:20 -05:00
Wei Guangjing
3aec5516ed 6l: windows/amd64 port
R=rsc
CC=golang-dev
https://golang.org/cl/3746044
2011-01-20 09:21:10 -05:00
Russ Cox
0849944694 gc: delete float, complex
rename cmplx -> complex

R=ken2
CC=golang-dev
https://golang.org/cl/4071041
2011-01-19 23:08:11 -05:00
Alex Brainman
48d2de7eb9 8l: pe changes
Dll names and function names padded to even size.
Refactoring of imports writing code.

R=rsc
CC=golang-dev
https://golang.org/cl/3804042
2011-01-19 15:10:01 -05:00
Ian Lance Taylor
3a43ff1a77 ld: Fix exported dynamic symbols on Mach-O.
* Avoid confusion between imported and exported symbols.
* Record number of imported and exported symbols correctly.
* Explictly relocate SMACHOSYM section, since it is not in datap.

R=rsc
CC=golang-dev
https://golang.org/cl/3920042
2011-01-11 13:56:47 -08:00
Ian Lance Taylor
882f9d6d7a ld: Permit an Mach-O symbol to be exported in the dynamic symbol table.
Submitting TBR to fix Darwin build.

R=rsc
TBR=rsc
CC=golang-dev
https://golang.org/cl/3912043
2011-01-11 11:22:47 -08:00
Ian Lance Taylor
1b2d5b4c93 ld: Permit an ELF symbol to be exported in the dynamic symbol table.
This permits exporting crosscall2 from the runtime/cgo
package.

R=rsc
CC=golang-dev
https://golang.org/cl/3885041
2011-01-06 16:37:05 -08:00
Russ Cox
8ec6f7cd11 ld: ignore stab symbols
Makes 6l work better on OS X 10.5.

Fixes #1352.
Fixes #1353.

R=r
CC=golang-dev
https://golang.org/cl/3661042
2010-12-17 10:03:43 -08:00
Russ Cox
01464cf956 ld: allow relocations pointing at ELF .bss symbols
R=r, r2
CC=golang-dev
https://golang.org/cl/3710042
2010-12-17 09:53:50 -08:00
Russ Cox
1116ec4f20 ld: text segment should not be writable
R=adg
CC=golang-dev
https://golang.org/cl/3708041
2010-12-15 19:29:53 -08:00
Alex Brainman
f8b7eda5f6 8l: remove unneeded windows check
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/3691042
2010-12-16 12:19:59 +11:00
Russ Cox
33405ecc86 fix freebsd build
R=iant, r
CC=dho, golang-dev
https://golang.org/cl/3687041
2010-12-15 17:20:26 -05:00
Russ Cox
0c54225b51 remove nacl
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
2010-12-15 11:49:23 -05:00
Luuk van Dijk
7a4ce23d65 [68]l and runtime: GDB support for interfaces and goroutines.
R=rsc
CC=golang-dev
https://golang.org/cl/3477041
2010-12-15 12:00:43 +01:00
Russ Cox
88cf5564fc ld: missing prototype
R=ken2
CC=golang-dev
https://golang.org/cl/3620041
2010-12-13 15:26:52 -05:00
Russ Cox
c7c16175e0 ld: allow .o files with no symbols
Don't crash in dwarf for foreign functions.

R=ken2
CC=golang-dev
https://golang.org/cl/3576043
2010-12-13 10:05:07 -05:00
Wei Guangjing
e04ef7769e Fix windows build.
R=brainman, rsc
CC=golang-dev
https://golang.org/cl/3533041
2010-12-13 16:41:02 +11:00
Eoghan Sherry
40ff071e9b 5g/8g, 8l, ld, prof: fix output of 32-bit values
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-12 14:40:19 -05:00
Russ Cox
839abc2ea7 5l (and 6l, 8l, ld): more arm build fixes
R=ken2
CC=golang-dev
https://golang.org/cl/3521041
2010-12-08 15:44:59 -05:00
Russ Cox
f5690004c2 6l, 8l: support for linking ELF and Mach-O .o files
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-08 13:56:43 -05:00
Russ Cox
cf42a45587 ld: reading of Mach-O object files
R=iant
CC=golang-dev
https://golang.org/cl/3431045
2010-12-08 13:53:24 -05:00
Russ Cox
8132f1d016 6l, 8l: minor changes & cleanup
R=ken2, ken3
CC=golang-dev
https://golang.org/cl/3505041
2010-12-08 13:53:07 -05:00
Russ Cox
4d8d6d5cda ld: reading of ELF object files
R=iant
CC=golang-dev
https://golang.org/cl/3507041
2010-12-08 13:52:59 -05:00
Russ Cox
7431a3165e ld: re-add ELF symbol tables
R=iant
CC=golang-dev
https://golang.org/cl/3506041
2010-12-08 13:52:50 -05:00
Eoghan Sherry
63544c4754 ld: fix dwarf decoding of 64-bit reflect values
R=rsc
CC=golang-dev
https://golang.org/cl/3002041
2010-12-07 17:20:52 -05:00
Wei Guangjing
70deac67cf 8l : add dynimport to import table in Windows PE, initial make cgo dll work.
R=rsc, brainman, Joe Poirier, mattn
CC=golang-dev
https://golang.org/cl/2166041
2010-12-07 15:28:33 -05:00
Yuval Pavel Zholkover
8221eb9103 8l, runtime: fix Plan 9 386 build.
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-12-06 16:38:28 -05:00
Luuk van Dijk
9a71bb00bb [68]l: generate debug info for builtin structured types. prettyprinting in gdb.
R=rsc
CC=golang-dev
https://golang.org/cl/3309041
2010-12-03 19:19:33 +01:00
Luuk van Dijk
f08baa38f8 [68]l: correct dwarf location for globals and ranges for arrays.
R=rsc
CC=golang-dev
https://golang.org/cl/3306042
2010-11-29 19:25:33 +01:00
Luuk van Dijk
fbd92dba96 6l/8l: generate dwarf variable names with disambiguating suffix.
R=rsc
CC=golang-dev
https://golang.org/cl/2733042
2010-11-08 19:48:21 +01:00
Ian Lance Taylor
d2d650bdc9 Use future official DWARF language code for Go.
http://dwarfstd.org/ShowIssue.php?issue=101014.1&type=open

Informally accepted for future DWARF 5.

R=lvd
CC=golang-dev, rsc
https://golang.org/cl/2881042
2010-11-04 08:45:25 -07:00
Alex Brainman
8f8f625cb1 8l: pe generation fixes
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-11-02 10:56:56 +11:00
Luuk van Dijk
4228e62259 6l/8l: global and local variables and type info.
R=rsc
CC=golang-dev
https://golang.org/cl/2201044
2010-10-24 23:07:52 +02:00
Russ Cox
e5e9211071 5l, 6l, 8l: introduce sub-symbols
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-22 15:27:50 -04:00
Russ Cox
49084db386 ld: abandon symbol-driven archive loading
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
2010-10-21 11:39:47 -04:00
Russ Cox
69188ad9bb arm: prop up software floating point
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-21 06:56:20 +02:00
Alex Brainman
5e4963d9e8 8l: fix windows build
R=rsc
CC=golang-dev
https://golang.org/cl/2595041
2010-10-20 14:06:00 +11:00
Russ Cox
d5dffb9f29 8l: fix references to INITDAT in windows pe.c
R=ken2
CC=golang-dev
https://golang.org/cl/2588041
2010-10-19 18:17:07 -04:00
Russ Cox
19fd5c787f 5l, 6l, 8l: link pclntab and symtab as ordinary rodata symbols
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-19 18:07:19 -04:00
Russ Cox
01df088f8d 5l, 6l, 8l: separate pass to fix addresses
Lay out code before data.

R=ken2
CC=golang-dev
https://golang.org/cl/2490043
2010-10-19 13:08:17 -04:00
Luuk van Dijk
a647f59c1f [68]l: proper end of instruction ranges in dwarf.
R=rsc
CC=golang-dev
https://golang.org/cl/2542042
2010-10-17 22:35:55 +02:00
Luuk van Dijk
cc9e6b5cdb [68]l: fix off by one instruction in dwarf frame unwinding.
R=rsc
CC=golang-dev
https://golang.org/cl/2543043
2010-10-17 21:13:55 +02:00
Wei Guangjing
77eb94c032 8l: fix windows build.
R=rsc, brainman
CC=golang-dev
https://golang.org/cl/2543042
2010-10-15 23:37:14 -04:00
Russ Cox
6e18e8c82f 8l: blind attempt to fix windows build
or at least gather more information

R=ken2
CC=golang-dev
https://golang.org/cl/2515042
2010-10-15 15:29:25 -04:00
Russ Cox
9c20485268 6l: function at a time code layout
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-15 15:18:47 -04:00
Russ Cox
be2c2120d0 5l, 6l, 8l: accumulate data image during import
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
2010-10-14 23:48:40 -04:00
Russ Cox
d9c989fa25 various: avoid %ld etc
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
2010-10-13 16:20:22 -04:00
Russ Cox
085be1740a 5l, 6l, 8l: first pass cleanup
* 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
2010-10-13 15:51:21 -04:00
Russ Cox
d42903119b 5l, 6l, 8l: indent, outdent
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
2010-10-13 15:19:53 -04:00
Jim McGrath
8a1b2e59ef 6l: work with OS X nm/otool
6l was skipping emitting the (2 byte) symbol table if there were no imported or exported
symbols. You can't just drop the symbol table entirely - the linker dies if you have
a linkedit section but no table. You can omit the linkedit section or both the linkedit
and the dlyd parts in the right circumstances, but that seems much more risky to me.

R=rsc
CC=golang-dev
https://golang.org/cl/2421042
2010-10-12 16:52:17 -04:00
Russ Cox
054be1b6c3 ld: be less picky about bad line number info
Fixes #1175.

R=lvd
CC=golang-dev
https://golang.org/cl/2439041
2010-10-11 16:21:03 -04:00
Jim McGrath
3d0726b04d 6l: correct offset for __nl_symbol_ptr in Mach-O.
Fixes malformed object message from nm etc.
Fixes #1180.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/2390042
2010-10-11 14:45:01 -04:00
Jim McGrath
0f6926474f 6l: fix Mach-O LC_RPATH
Fixes #1177.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/2387042
2010-10-11 14:39:41 -04:00
Luuk van Dijk
2ad521c19a [568]a: precise linenumbers for statements.
R=rsc, ken2, r, rsc1
CC=golang-dev
https://golang.org/cl/2297042
2010-10-07 11:13:06 +02:00
Russ Cox
30edda690f ld: share asmlc
R=ken2
CC=golang-dev
https://golang.org/cl/2373043
2010-10-06 09:52:54 -04:00
Russ Cox
05cc83bf4e various: appease the ubuntu gcc monster
Silence warnings about not checking
return values from read and write system calls.

R=r, r2
CC=golang-dev
https://golang.org/cl/2258045
2010-09-28 13:00:13 -04:00
Ken Thompson
103d756663 loader fix
static init redo

R=rsc
CC=golang-dev
https://golang.org/cl/2254041
2010-09-20 14:23:25 -07:00
Luuk van Dijk
eb572e0174 6l/8l: emit DWARF frame info.
R=rsc, ken2, r
CC=golang-dev
https://golang.org/cl/2151044
2010-09-20 18:44:19 +02:00
Russ Cox
af12feb8d5 6l, 8l: clean up ELF code, fix NaCl
R=r
CC=golang-dev
https://golang.org/cl/2221042
2010-09-19 22:10:34 -04:00
Russ Cox
d64a2bddf0 tabs
TBR=lvd
CC=golang-dev
https://golang.org/cl/2194041
2010-09-14 11:16:57 -04:00
Russ Cox
698fb4f192 6g, 6l, 8g, 8l: move read-only data to text segment
Changing 5g and 5l too, but it doesn't work yet.

R=ken2
CC=golang-dev
https://golang.org/cl/2136047
2010-09-12 00:17:44 -04:00
Dan Sinclair
122f3980c7 ld: handle quoted spaces in package path
Fixes #1087.

R=rsc
CC=golang-dev
https://golang.org/cl/2172041
2010-09-10 13:59:20 -04:00
Luuk van Dijk
728003e340 6l/8l: emit DWARF in macho.
R=rsc, r, ken2
CC=golang-dev
https://golang.org/cl/2128041
2010-09-01 21:54:28 +02:00
Luuk van Dijk
b433552ebc 8l: emit DWARF in ELF.
R=rsc, r, ken2
CC=golang-dev
https://golang.org/cl/2004046
2010-08-30 22:20:38 +02:00
Luuk van Dijk
ca9098ee94 Dwarf output for 6l.
Part 1, general scaffolding and pc/lc sections.

R=rsc, r, ken2
CC=golang-dev
https://golang.org/cl/1987042
2010-08-18 16:53:22 +02:00
Russ Cox
9a442211c6 6l: more invalid input files
Fixes #963.
Fixes #964.

R=r
CC=golang-dev
https://golang.org/cl/1874045
2010-07-26 17:34:02 -07:00
Russ Cox
916f896a3b ld: various bug fixes
Fixes #937.
Fixes #938.
Fixes #939.
Fixes #940.

R=r
CC=golang-dev
https://golang.org/cl/1886043
2010-07-21 13:44:49 -07:00
Russ Cox
e692977af3 5l, 6l, 8l: reject invalid input files
Fixes #925.
Fixes #926.
Fixes #927.
Fixes #928.
Fixes #929.
Fixes #930.

R=r
CC=golang-dev
https://golang.org/cl/1752044
2010-07-16 16:16:17 -07:00
Russ Cox
44eaaaaa78 ld: fix handling of "". names in #pragma dynimport/dynexport
Fixes #728.

R=r
CC=golang-dev
https://golang.org/cl/1706053
2010-07-01 21:48:13 -07:00
Russ Cox
489494cac3 cgo: use slash-free relative paths for .so references
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
2010-06-30 23:31:27 -07:00
Russ Cox
829896168c ld: fix implementation of -u
R=r
CC=golang-dev
https://golang.org/cl/1678046
2010-06-29 18:59:48 -07:00
Russ Cox
6519a6ba5b ld: add -u flag to check safe bits; discard old -u, -x flags
R=r, r2
CC=golang-dev
https://golang.org/cl/1707043
2010-06-21 18:03:49 -07:00
Russ Cox
74a23646bc 8l: fix absolute path detection on Windows
Fixes #755.

R=ken2
CC=golang-dev
https://golang.org/cl/965047
2010-04-30 12:48:03 -07:00
Russ Cox
000ab98df6 5l, 6l, 8l, runtime: make -s binaries work
5l, 6l, 8l: change ELF header so that strip doesn't destroy binary

Fixes #261.

R=iant, r
CC=golang-dev
https://golang.org/cl/994044
2010-04-27 22:40:26 -07:00
Evan Shaw
30f981d980 8l: add DOS stub to PE binaries
R=rsc
CC=golang-dev
https://golang.org/cl/915041
2010-04-13 16:13:53 -07:00
Ian Lance Taylor
732f3919ab Support #pragma dynexport on OS X.
R=rsc
CC=golang-dev
https://golang.org/cl/733041
2010-03-25 11:45:18 -07:00
Ian Lance Taylor
9e0ae94e72 Add support for #pragma dynexport.
R=rsc
CC=golang-dev
https://golang.org/cl/661043
2010-03-23 06:46:30 -07:00
Ian Lance Taylor
f54d73b880 Rename dynld to dynimport throughout.
Cgo users will need to rerun cgo.

R=rsc
CC=golang-dev
https://golang.org/cl/692041
2010-03-22 19:58:55 -07:00
Alex Brainman
3b1a71862e 8l: pe executable building code changed to include import table for kernel32.dll functions
Fixes #586.

R=rsc
CC=golang-dev
https://golang.org/cl/203060
2010-02-10 00:47:52 -08:00
Russ Cox
f9f66b97e2 ld: unused variable
R=adg
CC=golang-dev
https://golang.org/cl/207050
2010-02-10 00:44:22 -08:00
Andrew Gerrand
8ec9ffc742 6l: move mapped symbol table lower in memory
Allows binary to run on some Linux system.

Fix for issue 365.

R=rsc
CC=golang-dev
https://golang.org/cl/199096
2010-02-04 12:46:11 -08:00
Kai Backman
2f1a321d4f search for runtime.a in the package path instead of hardcoding
the location. remove last remnants of broken -l flag.

R=rsc
CC=golang-dev
https://golang.org/cl/201042
2010-02-03 22:31:38 -08:00
Russ Cox
00f4c6a1b5 ld: include main and runtime in the library loop
Fixes #585.

R=r
CC=golang-dev
https://golang.org/cl/195075
2010-02-03 16:30:45 -08:00
Russ Cox
1f11ece67f nacl: fix build, finally fixed 8l convergence bug
R=r
CC=golang-dev
https://golang.org/cl/199042
2010-02-01 15:20:19 -08:00
Russ Cox
60a6ec1c93 ld: typo
R=ken2
CC=golang-dev
https://golang.org/cl/194073
2010-01-25 18:48:18 -08:00
Russ Cox
531e6b77c8 eliminate package global name space
R=ken2
CC=golang-dev
https://golang.org/cl/194071
2010-01-25 18:31:35 -08:00
Russ Cox
69e244a104 ld: do not load the same object file multiple times.
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
2010-01-25 08:53:27 -08:00