The original version of applyRelocationsARM was added in
http://golang.org/cl/7266. It was added to fix the ARM build, which
had been broken by http://golang.org/cl/6780.
Before CL 6780, there was no relocation processing for ARM. CL 6780
changed the code to require relocation processing for every supported
target. CL 7266 fixed the ARM build by adding a relocation processing
function, but in fact no actual processing was done. The code only
looked for REL32 relocations, but ARM debug info has no such
relocations. The test case added in CL 7266 doesn't have any either.
This didn't matter because no relocation processing was required on
ARM, at least not for GCC-generated debug info. GCC generates ABS32
relocations, but only against section symbols which have the value 0.
Therefore, the addition done by correct handling of ABS32 doesn't
change anything.
Clang, however, generates ABS32 relocations against local symbols,
some of which have non-zero values. For those, we need to handle
ABS32 relocations.
This patch corrects the CL 7266 to look for ABS32 relocations instead
of REL32 relocations. The code was already written to correctly
handle ABS32 relocations, it just mistakenly said REL32.
This is the ARM equivalent of https://golang.org/cl/96680045, which
fixed the same problem in the same way for clang on 386.
With this patch, clang-3.5 can be used to build Go on ARM GNU/Linux.
Fixes#8980.
Change-Id: I0c2d72eadfe6373bde99cd03eee40de6a582dda1
Reviewed-on: https://go-review.googlesource.com/11222
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
These were found by grepping the comments from the go code and feeding
the output to aspell.
Change-Id: Id734d6c8d1938ec3c36bd94a4dbbad577e3ad395
Reviewed-on: https://go-review.googlesource.com/10941
Reviewed-by: Aamir Khan <syst3m.w0rm@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This CL fixes the build to use the newly created go tool compile
and go tool link in place of go tool 5g, go tool 5l, and so on.
See golang-dev thread titled "go tool compile, etc" for background.
Although it was not a primary motivation, this conversion does
reduce the wall clock time and cpu time required for make.bash
by about 10%.
Change-Id: I79cbbdb676cab029db8aeefb99a53178ff55f98d
Reviewed-on: https://go-review.googlesource.com/10288
Reviewed-by: Rob Pike <r@golang.org>
When AttrByteSize is not present for a type, we can still determine the
size in two more cases: when the type is a Typedef referring to another
type, and when the type is a pointer and we know the default address
size.
entry.go: return after setting an error if the offset is out of range.
Change-Id: I63a922ca4e4ad2fc9e9be3e5b47f59fae7d0eb5c
Reviewed-on: https://go-review.googlesource.com/9663
Reviewed-by: Austin Clements <austin@google.com>
Currently, Entry has a Val method that looks up an attribute and
returns its value. Now that Field has more fields than the attribute
and its value, it's useful to return the whole Field and let the
caller retrieve the parts it needs.
This change adds an AttrField method to Entry that does the same
lookup at Val, but returns the whole *Field rather than just the
value.
Change-Id: Ic629744c14c0e09d7528fa1026b0e1857789948c
Reviewed-on: https://go-review.googlesource.com/8503
Reviewed-by: Ian Lance Taylor <iant@golang.org>
To return DWARF attribute values, debug/dwarf maps the DWARF attribute
value classes to Go types. Unfortunately, this mapping is ambiguous in
a way that makes it impossible to correctly interpret some DWARF
attributes as of DWARF 4. For example, AttrStartScope can be either a
constant or a rangelistptr. The attribute is interpreted differently
depending on its class, but debug/dwarf maps both classes to int64, so
the caller can't distinguish them from the Go type.
AttrDataMemberLocation is similar.
To address this, this change adds a field to type Field that indicates
the exact DWARF attribute value class of that field's value. This
makes it possible to distinguish value classes that can't be
distinguished by their Go type alone.
The root of this type ambiguity was DWARF itself. For example, DWARF 2
made no distinction between constants that were just constants and
constants that were section offsets because no attribute could have
both meanings. Hence, the single int64 type was sufficient. To avoid
introducing just another layer of ambiguity, this change takes pains
to canonicalize ambiguous classes in DWARF 2 and 3 files into the
unambiguous classes of DWARF 4.
Of course, there's no guarantee that future DWARF versions won't do
the same thing again and further subdivide the DWARF 4 classes. This
change gets ahead of this somewhat by distinguishing the various *ptr
classes even though the encoding does not. If there's some other form
of split, we can handle this in a backwards-compatible way by
introducing, for example, a Class5 field and type.
Change-Id: I4ef96d1223b0fd7f96ecf44fcc0e704a36af02b4
Reviewed-on: https://go-review.googlesource.com/8502
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Skip the test when there is no .gosymtab section in the executable
rather than crashing.
Change-Id: Ieb3df07e307f50c33cdafab38f9b5d1ac0e55c04
Reviewed-on: https://go-review.googlesource.com/5110
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
Currently, the only way to know the Go type of an attribute of some
DWARF attribute class was to read the dwarf package code (or
experiment). This makes it hard to go from the DWARF specification to
writing code that uses the dwarf package.
Fix this by adding a table to the documentation comment of the Field
type that gives the correspondence between DWARF attribute classes and
Go types.
Change-Id: I57c678a551fa1eb46f8207085d5a53d44985e3e7
Reviewed-on: https://go-review.googlesource.com/7280
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
The debug/dwarf and encoding/asn1 examples were added in 2009, a few
months before Go added implicit semicolons, and never updated.
The go/ast node types have always been named just "Expr", "Stmt", and
"Decl", so the comments about "ExprNode", "StmtNode", and "DeclNode"
were likely just mistaken because the interface tag methods are
"exprNode", "stmtNode", and "declNode", respectively.
Change-Id: I9d138cc3a16c1a51453da1406914d7b320bf6270
Reviewed-on: https://go-review.googlesource.com/7980
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Many headers in DWARF sections have a "unit length" that can be either
4 bytes or 12 bytes and indicates both the length of the unit and
whether the unit is in 32-bit or 64-bit format.
Currently, we implement unit length parsing in four different places.
Add a "unitLength" method to buf that parses a unit length and use it
in these four places.
Change-Id: I7950b91caaa92aa5e19aa63debc8ae46178ecc4d
Reviewed-on: https://go-review.googlesource.com/7281
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This change adds the minimum necessary to implement applyRelocations.
For adg, this code uses the switch statement.
Change-Id: I0989daab8d0e36c2a4f6a315ced258b832744616
Reviewed-on: https://go-review.googlesource.com/7266
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This adds simple ELF test binaries generated by gcc and clang and
compares the line tables returned by the line table reader against
tables based on the output of readelf.
The binaries were generated with
# gcc --version | head -n1
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
# gcc -g -o line-gcc.elf line*.c
# clang --version | head -n1
Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
# clang -g -o line-clang.elf line*.c
Change-Id: Id210fdc1d007ac9719e8f5dc845f2b94eed12234
Reviewed-on: https://go-review.googlesource.com/7070
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
This implements a LineReader for line tables that parallels the
existing Reader for debug entries.
This code is partly based on the debug subrepo's fork of dwarf, but it
is a more complete (and, I believe, correct) implementation of the
spec and exposes a more general API. While the debug subrepo's
implementation exposed only a PC-to-line function, this version
exposes the line table rows to the caller. This way the caller can
make its own trade-offs when implementing PC-to-line (or line-to-PC),
such as whether or not to build an index for fast lookup.
Change-Id: Ie157bc817f55e940b6f2e1ae010c5a4e1f29c5c8
Reviewed-on: https://go-review.googlesource.com/6734
Reviewed-by: Nigel Tao <nigeltao@golang.org>
This factors out the code for finding which unit contains an offset in
the "info" section. The new code also replaces linear search with a
binary search. The line table reader will also need this
functionality.
Change-Id: I2076e4fc6719b6f06fd2796cbbc7548ec1876cb3
Reviewed-on: https://go-review.googlesource.com/6733
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Change-Id: Ia6f9bd77a3d4250339dcb054edc76942864dd358
Reviewed-on: https://go-review.googlesource.com/6781
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Previously, different DWARF sections had relocations applied in very
different ways. .debug_info was relocated, but only on x86-64 and 386
and using hard-coded relocation section names instead of relocation
links. .debug_abbrev and .debug_str were never relocated (which is
excusable because they shouldn't need it). .debug_types sections were
relocated on all architectures and found their relocation section
using a relocation link because section names could be ambiguous.
Simplify all of this so that every DWARF section that has a linked
relocation section gets those relocations applied.
This prepares this code to load .debug_line sections without the need
for yet more ad hoc relocation logic.
Change-Id: Ia00ac8e656b22f22bb31a5f6ef9b0f23cda64d19
Reviewed-on: https://go-review.googlesource.com/6780
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This CL will break any uses of 'go tool 5a' etc.
That is intentional.
Code that invokes an assembler directly should be updated to use go tool asm.
We plan to keep the old5a around for bit-for-bit verification during
the release testing phase, but we plan to remove those tools for the
actual release. Renaming the directory now makes sure that lingering
references to 'go tool 5a' will be caught, changed to use asm, and
tested during the release evaluation.
Change-Id: I98748a7ddb34cc7f1b151c2ef421d3656821f5c2
Reviewed-on: https://go-review.googlesource.com/6366
Reviewed-by: Rob Pike <r@golang.org>
debug/goobj is not ready to be published but it is
needed for the various binary-reading commands.
Move to cmd/internal/goobj.
(The Go 1.3 release branch deleted it, but that's not
an option anymore due to the command dependencies.
The API is still not vetted nor terribly well designed.)
LGTM=adg, dsymonds
R=adg, dsymonds
CC=golang-codereviews
https://golang.org/cl/174250043
This is to reduce the delta between dev.cc and dev.garbage to just garbage collector changes.
These are the files that had merge conflicts and have been edited by hand:
malloc.go
mem_linux.go
mgc.go
os1_linux.go
proc1.go
panic1.go
runtime1.go
LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/174180043
This brings dev.power64 up-to-date with the current tip of
default. go_bootstrap is still panicking with a bad defer
when initializing the runtime (even on amd64).
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/152570049
This also removes pkg/runtime/traceback_lr.c, which was ported
to Go in an earlier commit and then moved to
runtime/traceback.go.
Reviewer: rsc@golang.org
rsc: LGTM