1
0
mirror of https://github.com/golang/go synced 2024-11-05 17:46:16 -07:00

cmd/link, cmd/internal/goobj: update constants, regenerate testdata

The constants in cmd/internal/goobj had gone stale (we had three copies of
these constants, working on reducing that was what got me to noticing this).

Some of the changes to link.hello.darwin.amd64 are the change from absolute
to %rip-relative addressing, a change which happened quite a while ago...

Depends on http://golang.org/cl/9113.

Fixes #10501.

Change-Id: Iaa1511f458a32228c2df2ccd0076bb9ae212a035
Reviewed-on: https://go-review.googlesource.com/9105
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:
Michael Hudson-Doyle 2015-04-20 11:53:20 +12:00 committed by Ian Lance Taylor
parent 4655aadd00
commit 68f5570032
11 changed files with 63 additions and 67 deletions

View File

@ -12,6 +12,7 @@ package goobj
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"cmd/internal/obj"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@ -31,45 +32,46 @@ const (
_ SymKind = iota _ SymKind = iota
// readonly, executable // readonly, executable
STEXT STEXT SymKind = obj.STEXT
SELFRXSECT SELFRXSECT SymKind = obj.SELFRXSECT
// readonly, non-executable // readonly, non-executable
STYPE STYPE SymKind = obj.STYPE
SSTRING SSTRING SymKind = obj.SSTRING
SGOSTRING SGOSTRING SymKind = obj.SGOSTRING
SGOFUNC SGOFUNC SymKind = obj.SGOFUNC
SRODATA SRODATA SymKind = obj.SRODATA
SFUNCTAB SFUNCTAB SymKind = obj.SFUNCTAB
STYPELINK STYPELINK SymKind = obj.STYPELINK
SSYMTAB // TODO: move to unmapped section SSYMTAB SymKind = obj.SSYMTAB // TODO: move to unmapped section
SPCLNTAB SPCLNTAB SymKind = obj.SPCLNTAB
SELFROSECT SELFROSECT SymKind = obj.SELFROSECT
// writable, non-executable // writable, non-executable
SMACHOPLT SMACHOPLT SymKind = obj.SMACHOPLT
SELFSECT SELFSECT SymKind = obj.SELFSECT
SMACHO // Mach-O __nl_symbol_ptr SMACHO SymKind = obj.SMACHO // Mach-O __nl_symbol_ptr
SMACHOGOT SMACHOGOT SymKind = obj.SMACHOGOT
SNOPTRDATA SWINDOWS SymKind = obj.SWINDOWS
SINITARR SELFGOT SymKind = obj.SELFGOT
SDATA SNOPTRDATA SymKind = obj.SNOPTRDATA
SWINDOWS SINITARR SymKind = obj.SINITARR
SBSS SDATA SymKind = obj.SDATA
SNOPTRBSS SBSS SymKind = obj.SBSS
STLSBSS SNOPTRBSS SymKind = obj.SNOPTRBSS
STLSBSS SymKind = obj.STLSBSS
// not mapped // not mapped
SXREF SXREF SymKind = obj.SXREF
SMACHOSYMSTR SMACHOSYMSTR SymKind = obj.SMACHOSYMSTR
SMACHOSYMTAB SMACHOSYMTAB SymKind = obj.SMACHOSYMTAB
SMACHOINDIRECTPLT SMACHOINDIRECTPLT SymKind = obj.SMACHOINDIRECTPLT
SMACHOINDIRECTGOT SMACHOINDIRECTGOT SymKind = obj.SMACHOINDIRECTGOT
SFILE SFILE SymKind = obj.SFILE
SFILEPATH SFILEPATH SymKind = obj.SFILEPATH
SCONST SCONST SymKind = obj.SCONST
SDYNIMPORT SDYNIMPORT SymKind = obj.SDYNIMPORT
SHOSTOBJ SHOSTOBJ SymKind = obj.SHOSTOBJ
) )
var symKindStrings = []string{ var symKindStrings = []string{

View File

@ -6,7 +6,10 @@
package main package main
import "os" import (
"cmd/internal/obj"
"os"
)
// load allocates segment images, populates them with data // load allocates segment images, populates them with data
// read from package files, and applies relocations to the data. // read from package files, and applies relocations to the data.
@ -73,17 +76,6 @@ func (p *Prog) loadPackage(pkg *Package) {
} }
} }
// TODO(rsc): Define full enumeration for relocation types.
const (
R_ADDR = 1
R_SIZE = 2
R_CALL = 3
R_CALLARM = 4
R_CALLIND = 5
R_CONST = 6
R_PCREL = 7
)
// relocateSym applies relocations to sym's data. // relocateSym applies relocations to sym's data.
func (p *Prog) relocateSym(sym *Sym, data []byte) { func (p *Prog) relocateSym(sym *Sym, data []byte) {
for i := range sym.Reloc { for i := range sym.Reloc {
@ -97,9 +89,9 @@ func (p *Prog) relocateSym(sym *Sym, data []byte) {
switch r.Type { switch r.Type {
default: default:
p.errorf("%v: unknown relocation type %d", sym, r.Type) p.errorf("%v: unknown relocation type %d", sym, r.Type)
case R_ADDR, R_CALLIND: case obj.R_ADDR, obj.R_CALLIND:
// ok // ok
case R_PCREL, R_CALL: case obj.R_PCREL, obj.R_CALL:
val -= sym.Addr + Addr(r.Offset+r.Size) val -= sym.Addr + Addr(r.Offset+r.Size)
} }
frag := data[r.Offset : r.Offset+r.Size] frag := data[r.Offset : r.Offset+r.Size]

View File

@ -8,6 +8,7 @@ package main
import ( import (
"cmd/internal/goobj" "cmd/internal/goobj"
"cmd/internal/obj"
"encoding/binary" "encoding/binary"
"os" "os"
"sort" "sort"
@ -371,7 +372,7 @@ func (b *SymBuffer) Addr(off int, sym goobj.SymID, symoff int64) int {
Size: b.ptrsize, Size: b.ptrsize,
Sym: sym, Sym: sym,
Add: int(symoff), Add: int(symoff),
Type: R_ADDR, Type: obj.R_ADDR,
}) })
return off + b.ptrsize return off + b.ptrsize
} }

View File

@ -9,7 +9,7 @@ ALL=\
all: $(ALL) all: $(ALL)
%.6: %.s %.6: %.s
GOARCH=amd64 GOOS=darwin go tool 6a -trimpath=$(shell pwd) $*.s GOARCH=amd64 GOOS=darwin go tool asm -I $(shell go env GOROOT)/pkg/include -trimpath=$(shell pwd) $*.s
pclntab.s: genpcln.go pclntab.s: genpcln.go
go run genpcln.go >pclntab.s go run genpcln.go >pclntab.s

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,23 +6,23 @@
* *
00000060 00 00 00 00 00 00 00 00 19 00 00 00 38 01 00 00 |............8...| 00000060 00 00 00 00 00 00 00 00 19 00 00 00 38 01 00 00 |............8...|
00000070 5f 5f 54 45 58 54 00 00 00 00 00 00 00 00 00 00 |__TEXT..........| 00000070 5f 5f 54 45 58 54 00 00 00 00 00 00 00 00 00 00 |__TEXT..........|
00000080 00 10 00 00 00 00 00 00 b0 10 00 00 00 00 00 00 |................| 00000080 00 10 00 00 00 00 00 00 c0 10 00 00 00 00 00 00 |................|
00000090 00 00 00 00 00 00 00 00 b0 10 00 00 00 00 00 00 |................| 00000090 00 00 00 00 00 00 00 00 c0 10 00 00 00 00 00 00 |................|
000000a0 07 00 00 00 05 00 00 00 03 00 00 00 00 00 00 00 |................| 000000a0 07 00 00 00 05 00 00 00 03 00 00 00 00 00 00 00 |................|
000000b0 5f 5f 74 65 78 74 00 00 00 00 00 00 00 00 00 00 |__text..........| 000000b0 5f 5f 74 65 78 74 00 00 00 00 00 00 00 00 00 00 |__text..........|
000000c0 5f 5f 54 45 58 54 00 00 00 00 00 00 00 00 00 00 |__TEXT..........| 000000c0 5f 5f 54 45 58 54 00 00 00 00 00 00 00 00 00 00 |__TEXT..........|
000000d0 00 20 00 00 00 00 00 00 20 00 00 00 00 00 00 00 |. ...... .......| 000000d0 00 20 00 00 00 00 00 00 30 00 00 00 00 00 00 00 |. ......0.......|
000000e0 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 000000e0 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000f0 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 000000f0 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000100 5f 5f 72 6f 64 61 74 61 00 00 00 00 00 00 00 00 |__rodata........| 00000100 5f 5f 72 6f 64 61 74 61 00 00 00 00 00 00 00 00 |__rodata........|
00000110 5f 5f 54 45 58 54 00 00 00 00 00 00 00 00 00 00 |__TEXT..........| 00000110 5f 5f 54 45 58 54 00 00 00 00 00 00 00 00 00 00 |__TEXT..........|
00000120 20 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ..............| 00000120 30 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |0 ..............|
00000130 20 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ...............| 00000130 30 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |0...............|
* *
00000150 5f 5f 66 75 6e 63 74 61 62 00 00 00 00 00 00 00 |__functab.......| 00000150 5f 5f 66 75 6e 63 74 61 62 00 00 00 00 00 00 00 |__functab.......|
00000160 5f 5f 54 45 58 54 00 00 00 00 00 00 00 00 00 00 |__TEXT..........| 00000160 5f 5f 54 45 58 54 00 00 00 00 00 00 00 00 00 00 |__TEXT..........|
00000170 20 20 00 00 00 00 00 00 90 00 00 00 00 00 00 00 | ..............| 00000170 30 20 00 00 00 00 00 00 90 00 00 00 00 00 00 00 |0 ..............|
00000180 20 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ...............| 00000180 30 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |0...............|
* *
000001a0 19 00 00 00 98 00 00 00 5f 5f 44 41 54 41 00 00 |........__DATA..| 000001a0 19 00 00 00 98 00 00 00 5f 5f 44 41 54 41 00 00 |........__DATA..|
000001b0 00 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 |.........0......| 000001b0 00 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 |.........0......|
@ -38,17 +38,18 @@
* *
000002c0 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 |......... ......| 000002c0 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 |......... ......|
* *
00001000 bf 01 00 00 00 be 00 30 00 00 ba 0c 00 00 00 b8 |.......0........| 00001000 bf 01 00 00 00 8d 35 f5 0f 00 00 ba 0c 00 00 00 |......5.........|
00001010 04 00 00 02 0f 05 31 ff b8 01 00 00 02 0f 05 c3 |......1.........| 00001010 b8 04 00 00 02 0f 05 31 ff b8 01 00 00 02 0f 05 |.......1........|
00001020 fb ff ff ff 00 00 01 08 01 00 00 00 00 00 00 00 |................| 00001020 c3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00001030 00 20 00 00 00 00 00 00 30 00 00 00 00 00 00 00 |. ......0.......| 00001030 fb ff ff ff 00 00 01 08 01 00 00 00 00 00 00 00 |................|
00001040 20 20 00 00 00 00 00 00 80 00 00 00 00 00 00 00 | ..............| 00001040 00 20 00 00 00 00 00 00 30 00 00 00 00 00 00 00 |. ......0.......|
00001050 00 20 00 00 00 00 00 00 58 00 00 00 00 00 00 80 |. ......X.......| 00001050 30 20 00 00 00 00 00 00 80 00 00 00 00 00 00 00 |0 ..............|
00001060 08 00 00 00 60 00 00 00 63 00 00 00 66 00 00 00 |....`...c...f...| 00001060 00 20 00 00 00 00 00 00 58 00 00 00 00 00 00 80 |. ......X.......|
00001070 00 00 00 00 00 00 00 00 5f 72 74 30 5f 67 6f 00 |........_rt0_go.| 00001070 08 00 00 00 60 00 00 00 63 00 00 00 66 00 00 00 |....`...c...f...|
00001080 02 20 00 04 20 00 06 05 02 05 02 05 02 05 02 02 |. .. ...........| 00001080 00 00 00 00 00 00 00 00 5f 72 74 30 5f 67 6f 00 |........_rt0_go.|
00001090 02 02 02 05 02 02 02 01 00 00 00 00 00 00 00 00 |................| 00001090 02 30 00 04 30 00 06 05 02 06 02 05 02 05 02 02 |.0..0...........|
000010a0 02 00 00 00 88 00 00 00 68 65 6c 6c 6f 2e 73 00 |........hello.s.| 000010a0 02 02 02 05 02 02 02 10 00 00 00 00 00 00 00 00 |................|
000010b0 02 00 00 00 88 00 00 00 68 65 6c 6c 6f 2e 73 00 |........hello.s.|
* *
00002000 68 65 6c 6c 6f 20 77 6f 72 6c 64 0a |hello world.| 00002000 68 65 6c 6c 6f 20 77 6f 72 6c 64 0a |hello world.|
0000200c 0000200c

Binary file not shown.