cmd/objdump: implement objdump of .o files

Update goobj reader so it can provide all the information
necessary to disassemble .o (and .a) files.

Grab architecture of .o files from header.

.o files have relocations in them.  This CL also contains a simple
mechanism to disassemble relocations and add relocation info as an extra
column in the output.

Fixes #13862

Change-Id: I608fd253ff1522ea47f18be650b38d528dae9054
Reviewed-on: https://go-review.googlesource.com/24818
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Keith Randall 2016-07-02 17:19:25 -07:00
parent 873dca4c17
commit a99f812cba
14 changed files with 187 additions and 42 deletions

View file

@ -442,14 +442,16 @@ const (
type Reloc struct {
Off int32
Siz uint8
Type int32
Type RelocType
Add int64
Sym *LSym
}
// Reloc.type
type RelocType int32
//go:generate stringer -type=RelocType
const (
R_ADDR = 1 + iota
R_ADDR RelocType = 1 + iota
// R_ADDRPOWER relocates a pair of "D-form" instructions (instructions with 16-bit
// immediates in the low half of the instruction word), usually addis followed by
// another add or a load, inserting the "high adjusted" 16 bits of the address of