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

163 Commits

Author SHA1 Message Date
Robert Sesek
a9600502bb debug/macho: Define CPU constants for other common architectures for OS X/iOS.
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/69100045
2014-02-27 19:11:03 -08:00
Russ Cox
964f6d3ec4 cmd/ld: remove Plan 9 symbol table
Update #6853

Nothing reads the Plan 9 symbol table anymore.
The last holdout was 'go tool nm', but since being rewritten in Go
it uses the standard symbol table for the binary format
(ELF, Mach-O, PE) instead.

Removing the Plan 9 symbol table saves ~15% disk space
on most binaries.

Two supporting changes included in this CL:

debug/gosym: use Go 1.2 pclntab to synthesize func-only
symbol table when there is no Plan 9 symbol table

debug/elf, debug/macho, debug/pe: ignore final EOF from ReadAt

LGTM=r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/65740045
2014-02-18 23:41:15 -05:00
Russ Cox
7056b05f7a debug/elf: correct test failure print
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/64380043
2014-02-15 20:00:15 -05:00
Robert Sesek
5bf35df491 debug/macho: Add support for opening fat/universal binaries.
New testdata was created from existing using:
$ lipo gcc-386-darwin-exec gcc-amd64-darwin-exec -create -output fat-gcc-386-amd64-darwin-exec

Fixes #7250.

LGTM=dave
R=golang-codereviews, dave, josharian, bradfitz
CC=golang-codereviews
https://golang.org/cl/60190043
2014-02-13 11:04:13 +11:00
Dave Cheney
951508671d debug/macho: add test file for CL 60190043
From the description of CL 60190043

debug/macho: Add support for opening fat/universal binaries.

New testdata was created from existing using:
$ lipo gcc-386-darwin-exec gcc-amd64-darwin-exec -create -output
fat-gcc-386-amd64-darwin-exec

Update #7250

LGTM=iant
R=golang-codereviews, gobot, dsymonds, iant
CC=golang-codereviews
https://golang.org/cl/61720044
2014-02-13 10:58:23 +11:00
Robert Dinu
c507601102 debug/pe: delete unnecessary type conversions
Fixes #7104.

LGTM=iant
R=golang-dev, iant
CC=golang-codereviews
https://golang.org/cl/61480049
2014-02-12 07:35:54 -08:00
Brad Fitzpatrick
a18f4ab569 all: use {bytes,strings}.NewReader instead of bytes.Buffers
Use the smaller read-only bytes.NewReader/strings.NewReader instead
of a bytes.Buffer when possible.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/54660045
2014-01-27 11:05:01 -08:00
Ian Lance Taylor
bd997b24f7 debug/dwarf, debug/elf: add support for reading DWARF 4 type info
In DWARF 4 the debug info for large types is put into
.debug_type sections, so that the linker can discard duplicate
info.  This change adds support for reading type units.

Another small change included here is that DWARF 3 supports
storing the byte offset of a struct field as a formData rather
than a formDwarfBlock.

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/56300043
2014-01-27 10:18:22 -08:00
David du Colombier
021c11683c debug/plan9obj: implement parsing of Plan 9 a.out executables
It implements parsing of the header and symbol table for both
32-bit and 64-bit Plan 9 binaries. The nm tool was updated to
use this package.

R=rsc, aram
CC=golang-codereviews
https://golang.org/cl/49970044
2014-01-22 23:30:52 +01:00
Russ Cox
2d55fdb507 debug/goobj: add String methods for SymID and SymKind
R=iant
CC=golang-codereviews
https://golang.org/cl/48890044
2014-01-08 20:37:41 -05:00
Michael Stapelberg
592416a387 debug/elf: add C source for testdata executables
This source file, when compiled with gcc 4.4.3 on Ubuntu lucid,
corresponds instruction for instruction to the binaries in the same
directory.

Shipping this source code file resolves http://bugs.debian.org/716853

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/46780043
2013-12-31 14:36:13 -08:00
Russ Cox
2404b7f168 debug/goobj: expand package prefix correctly
R=r, bradfitz
CC=golang-dev
https://golang.org/cl/43480049
2013-12-18 19:00:52 -05:00
Russ Cox
08b846b129 debug/goobj: add package for reading new Go object files
R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/40610043
2013-12-16 12:52:21 -05:00
Ian Lance Taylor
52ecd2ce96 debug/dwarf: remove unused field addrsize from Data
The addrsize field is not a constant for an entire executable
file, and is now handled by the dataFormat interface when
reading the data.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/41620043
2013-12-12 18:55:05 -08:00
Russ Cox
7dbbb53f37 debug/dwarf: add DWARF 4 form constants
Some versions of clang generate DWARF 4-format attributes
even when using -gdwarf-2. We don't care much about the
values, but we do need to be able to parse past them.

This fixes a bug in Go 1.2 rc2 reported via private mail using
a near-tip version of clang.

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/18460043
2013-10-29 10:36:51 -04:00
Ian Lance Taylor
c78d67fb86 debug/dwarf: report the value of an unrecognized attribute format
R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/14669045
2013-10-14 10:53:55 -07:00
Russ Cox
0965459bd9 debug/dwarf: handle surprising clang encoding
Fixes a bug in cgo on OS X using clang.
See golang.org/issue/6472 for details.

Fixes #6472.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14575043
2013-10-09 11:08:22 -04:00
Keith Randall
0273dc131e runtime: convert .s textflags from numbers to symbolic constants.
Remove NOPROF/DUPOK from everything.

Edits done with a script, except pclinetest.asm which depended
on the DUPOK flag on main().

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12613044
2013-08-07 12:20:05 -07:00
Brad Fitzpatrick
d8e27db395 undo CL 12486043 / ab644299d124
Uglier.

««« original CL description
all: use strings.IndexByte instead of Index where possible

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12486043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/12485044
2013-08-05 16:27:24 -07:00
Brad Fitzpatrick
4c772cda54 all: use strings.IndexByte instead of Index where possible
R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12486043
2013-08-05 15:46:06 -07:00
Rob Pike
abe384f68a all: be more idiomatic when documenting boolean return values.
Phrases like "returns whether or not the image is opaque" could be
describing what the function does (it always returns, regardless of
the opacity) or what it returns (a boolean indicating the opacity).
Even when the "or not" is missing, the phrasing is bizarre.

Go with "reports whether", which is still clunky but at least makes
it clear we're talking about the return value.

These were edited by hand. A few were cleaned up in other ways.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/11699043
2013-07-23 11:59:49 +10:00
Russ Cox
c758841853 cmd/ld, runtime: remove unused fields from Func
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11604043
2013-07-19 18:52:35 -04:00
Keith Randall
c38173bcbd debug/gosym: put pclinetest file in temporary directory
where it belongs.

R=rsc
CC=golang-dev
https://golang.org/cl/11596043
2013-07-19 12:31:42 -07:00
Russ Cox
72bd1a7e36 debug/gosym: avoid test failure on Windows
Would fix build if build hadn't already been broken with something else.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/11525043
2013-07-18 11:01:58 -04:00
Russ Cox
d7b4a09ca8 debug/gosym: update for Go 1.2 pcln table
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11495043
2013-07-18 10:12:14 -04:00
Dave Cheney
a00958aac6 all: avoid leaking fds during tests
trivial: it is not a serious problem to leak a fd in a short lived process, but it was obscuring my investigation of issue 5593.

R=golang-dev, iant, bradfitz
CC=golang-dev
https://golang.org/cl/10391043
2013-06-21 11:13:14 +10:00
Rémy Oudompheng
5060dded0f debug/elf: repair GNU version symbols.
After the revert of revision 9ea9e7e6e0c8
the related revision 76ff7da868c6 must be reverted too.

Fixes #5102.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7961044
2013-03-22 01:27:55 +01:00
Russ Cox
aafc444b74 debug/elf: restore Go 1.0 semantics for (*File).Symbols
Also adjust the implementation of applyRelocationsAMD64
so that the test added in CL 6848044 still passes.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7686049
2013-03-21 17:01:39 -04:00
Ian Lance Taylor
b79afe1b71 debug/dwarf: support for DWARF 3
R=rsc
CC=golang-dev
https://golang.org/cl/7662045
2013-03-19 13:59:37 -07:00
Rob Pike
ea196278aa debug/macho: add doc comment for FormatError
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7624044
2013-03-11 12:32:47 -07:00
Russ Cox
c8dcaeb25d cmd/ld, runtime: adjust symbol table representation
This CL changes the encoding used for the Go symbol table,
stored in the binary and used at run time. It does not change
any of the semantics or structure: the bits are just packed
a little differently.

The comment at the top of runtime/symtab.c describes the new format.

Compared to the Go 1.0 format, the main changes are:

* Store symbol addresses as full-pointer-sized host-endian values.
  (For 6g, this means addresses are 64-bit little-endian.)

* Store other values (frame sizes and so on) varint-encoded.

The second change more than compensates for the first:
for the godoc binary on OS X/amd64, the new symbol table
is 8% smaller than the old symbol table (1,425,668 down from 1,546,276).

This is a required step for allowing the host linker (gcc) to write
the final Go binary, since it will have to fill in the symbol address slots
(so the slots must be host-endian) and on 64-bit systems it may
choose addresses above 4 GB.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7403054
2013-02-26 22:38:14 -05:00
Robin Eklind
7fdaec6c2f debug/dwarf: add flag_present attribute encoding.
ref: http://www.dwarfstd.org/doc/DWARF4.pdf

Update #4829

R=minux.ma, iant
CC=dave, golang-dev
https://golang.org/cl/7354043
2013-02-20 00:58:31 +08:00
Rémy Oudompheng
75104237c8 all: make tests able to run multiple times.
It is now possible to run "go test -cpu=1,2,4 std"
successfully.

Fixes #3185.

R=golang-dev, dave, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7196052
2013-01-27 00:24:09 +01: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
Dave Cheney
7e9d9eb17b debug/elf: handle missing shstrndx in core files
Fixes #4481.

hello-world-core.gz was generated with a simple hello world c program and core dumped as suggested in the issue.

Also: add support for gz compressed test fixtures.

R=minux.ma, rsc, iant
CC=golang-dev
https://golang.org/cl/6936058
2012-12-18 07:58:22 +11:00
Joel Sing
8c96e6d740 debug/elf: fix offset for GNU version symbols
Since we no longer skip the first entry when reading a symbol table,
we no longer need to allow for the offset difference when processing
the GNU version symbols.

Unbreaks builds on Linux.

R=golang-dev, agl, iant
CC=golang-dev
https://golang.org/cl/6843057
2012-11-15 03:36:19 +11:00
Joel Sing
76689845e3 debug/elf: do not skip first symbol in the symbol table
Do not skip the first symbol in the symbol table. Any other indexes
into the symbol table (for example, indexes in relocation entries)
will now refer to the symbol following the one that was intended.

Add an object that contains debug relocations, which debug/dwarf
failed to decode correctly. Extend the relocation tests to cover
this case.

Note that the existing tests passed since the symbol following the
symbol that required relocation is also of type STT_SECTION.

Fixes #4107.

R=golang-dev, mikioh.mikioh, iant, iant
CC=golang-dev
https://golang.org/cl/6848044
2012-11-15 02:24:14 +11:00
Robin Eklind
e9f0fc8823 debug/pe: support PE files which contain no symbol table (if NumberOfSymbols is equal to 0 in the IMAGE_FILE_HEADER structure).
No longer assume that e_lfanew (in the IMAGE_DOS_HEADER strcuture) is always one byte. It is now regarded as a 4 byte uint32.

Fixes #4177.

R=golang-dev, alex.brainman, dave, minux.ma
CC=golang-dev
https://golang.org/cl/6587048
2012-10-09 11:15:53 +11:00
Joel Sing
5373e8a8d7 debug/pe: add symbol support
Add support for processing the COFF symbol table.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/6551045
2012-09-22 17:56:49 +10:00
Mike Rosset
cf06750372 debug/elf: Add support for getting DynTag string table values.
R=rsc
CC=golang-dev
https://golang.org/cl/6430064
2012-08-03 14:46:20 -04:00
Matthew Horsnell
875f34fd49 debug/elf: Expose entry point from Header in File struct.
Fixes #3470.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/6195074
2012-05-21 23:29:30 -04:00
Brad Fitzpatrick
494fe3b08f debug/gosym: in test, use temp binary name in /tmp, and clean up.
This fixes all.bash on shared machines.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5992078
2012-04-09 11:19:52 -07:00
Russ Cox
1a0c8fe9bb cmd/cgo: bug fixes
* disallow embedding of C type (Fixes issue 2552)
* detect 0-length array (Fixes issue 2806)
* use typedefs when possible, to avoid attribute((unavailable)) (Fixes issue 2888)
* print Go types constructed from C types using original C types (Fixes issue 2612)

This fix changes _cgo_export.h to repeat the preamble from import "C".
Otherwise the fix to issue 2612 is impossible, since it cannot refer to
types that have not been defined.  If people are using //export and
putting non-header information in the preamble, they will need to
refactor their code.

R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/5672080
2012-02-19 13:32:55 -05:00
Rob Pike
a15f59ef1d debug/dwarf: address TODO in doc comment for New
Fixes #2844.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5675072
2012-02-17 12:47:56 +11:00
David Symonds
7ec5499d36 debug/gosym: more carefully build the test binary.
TBR=r
CC=golang-dev
https://golang.org/cl/5676062
2012-02-16 15:06:12 +11:00
David Symonds
0fc441b053 debug/gosym: dump 6a/6l output to process stdout/stderr so we can see failures.
TBR=r
CC=golang-dev
https://golang.org/cl/5671060
2012-02-16 14:54:45 +11:00
David Symonds
3430599306 debug/gosym: Remove Makefile, rewrite test using go tool.
Update #2573.

R=r
CC=golang-dev
https://golang.org/cl/5656071
2012-02-16 14:47:14 +11:00
Andrew Gerrand
08e11187e6 debug/macho: dropped monstrous URL from package comment
Relax. It's still in macho.go.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5653054
2012-02-10 16:03:24 +11:00
Russ Cox
2050a9e478 build: remove Make.pkg, Make.tool
Consequently, remove many package Makefiles,
and shorten the few that remain.

gomake becomes 'go tool make'.

Turn off test phases of run.bash that do not work,
flagged with $BROKEN.  Future CLs will restore these,
but this seemed like a big enough CL already.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5601057
2012-01-30 23:43:46 -05:00
Mikio Hara
92c8df46c6 src: make use of runtime.GOOS, GOARCH instead of syscall.OS, ARCH
R=rsc, r
CC=golang-dev
https://golang.org/cl/5545048
2012-01-14 06:40:55 +09:00