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

218 Commits

Author SHA1 Message Date
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