Commit 021e0c5f authored by David Crawshaw's avatar David Crawshaw

cmd/link: add array append version of methods

Used by DWARF writer changes in a followup CL.

Change-Id: I6ec40dcfeaba909d9b8f6cf2603bc5b85c1fa873
Reviewed-on: https://go-review.googlesource.com/20073Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 62ac107a
......@@ -74,6 +74,9 @@ func linkarchinit() {
ld.Thearch.Lput = ld.Lputl
ld.Thearch.Wput = ld.Wputl
ld.Thearch.Vput = ld.Vputl
ld.Thearch.Append16 = ld.Append16l
ld.Thearch.Append32 = ld.Append32l
ld.Thearch.Append64 = ld.Append64l
ld.Thearch.Linuxdynld = "/lib64/ld-linux-x86-64.so.2"
ld.Thearch.Freebsddynld = "/libexec/ld-elf.so.1"
......
......@@ -70,6 +70,9 @@ func linkarchinit() {
ld.Thearch.Lput = ld.Lputl
ld.Thearch.Wput = ld.Wputl
ld.Thearch.Vput = ld.Vputl
ld.Thearch.Append16 = ld.Append16l
ld.Thearch.Append32 = ld.Append32l
ld.Thearch.Append64 = ld.Append64l
ld.Thearch.Linuxdynld = "/lib/ld-linux.so.3" // 2 for OABI, 3 for EABI
ld.Thearch.Freebsddynld = "/usr/libexec/ld-elf.so.1"
......
......@@ -70,6 +70,9 @@ func linkarchinit() {
ld.Thearch.Lput = ld.Lputl
ld.Thearch.Wput = ld.Wputl
ld.Thearch.Vput = ld.Vputl
ld.Thearch.Append16 = ld.Append16l
ld.Thearch.Append32 = ld.Append32l
ld.Thearch.Append64 = ld.Append64l
ld.Thearch.Linuxdynld = "/lib/ld-linux-aarch64.so.1"
......
......@@ -107,9 +107,12 @@ type Arch struct {
Gentext func()
Machoreloc1 func(*Reloc, int64) int
PEreloc1 func(*Reloc, int64) bool
Lput func(uint32)
Wput func(uint16)
Lput func(uint32)
Vput func(uint64)
Append16 func(b []byte, v uint16) []byte
Append32 func(b []byte, v uint32) []byte
Append64 func(b []byte, v uint64) []byte
}
type Rpath struct {
......
......@@ -296,6 +296,13 @@ func Wputb(w uint16) {
Cput(uint8(w))
}
func Append16b(b []byte, v uint16) []byte {
return append(b, uint8(v>>8), uint8(v))
}
func Append16l(b []byte, v uint16) []byte {
return append(b, uint8(v), uint8(v>>8))
}
func Lputb(l uint32) {
Cput(uint8(l >> 24))
Cput(uint8(l >> 16))
......@@ -310,6 +317,13 @@ func Lputl(l uint32) {
Cput(uint8(l >> 24))
}
func Append32b(b []byte, v uint32) []byte {
return append(b, uint8(v>>24), uint8(v>>16), uint8(v>>8), uint8(v))
}
func Append32l(b []byte, v uint32) []byte {
return append(b, uint8(v), uint8(v>>8), uint8(v>>16), uint8(v>>24))
}
func Vputb(v uint64) {
Lputb(uint32(v >> 32))
Lputb(uint32(v))
......@@ -320,6 +334,18 @@ func Vputl(v uint64) {
Lputl(uint32(v >> 32))
}
func Append64b(b []byte, v uint64) []byte {
b = Append32b(b, uint32(v>>32))
b = Append32b(b, uint32(v))
return b
}
func Append64l(b []byte, v uint64) []byte {
b = Append32l(b, uint32(v))
b = Append32l(b, uint32(v>>32))
return b
}
type byPkg []*Library
func (libs byPkg) Len() int {
......
......@@ -75,10 +75,16 @@ func linkarchinit() {
ld.Thearch.Lput = ld.Lputl
ld.Thearch.Wput = ld.Wputl
ld.Thearch.Vput = ld.Vputl
ld.Thearch.Append16 = ld.Append16l
ld.Thearch.Append32 = ld.Append32l
ld.Thearch.Append64 = ld.Append64l
} else {
ld.Thearch.Lput = ld.Lputb
ld.Thearch.Wput = ld.Wputb
ld.Thearch.Vput = ld.Vputb
ld.Thearch.Append16 = ld.Append16b
ld.Thearch.Append32 = ld.Append32b
ld.Thearch.Append64 = ld.Append64b
}
ld.Thearch.Linuxdynld = "/lib64/ld64.so.1"
......
......@@ -75,10 +75,16 @@ func linkarchinit() {
ld.Thearch.Lput = ld.Lputl
ld.Thearch.Wput = ld.Wputl
ld.Thearch.Vput = ld.Vputl
ld.Thearch.Append16 = ld.Append16l
ld.Thearch.Append32 = ld.Append32l
ld.Thearch.Append64 = ld.Append64l
} else {
ld.Thearch.Lput = ld.Lputb
ld.Thearch.Wput = ld.Wputb
ld.Thearch.Vput = ld.Vputb
ld.Thearch.Append16 = ld.Append16b
ld.Thearch.Append32 = ld.Append32b
ld.Thearch.Append64 = ld.Append64b
}
// TODO(austin): ABI v1 uses /usr/lib/ld.so.1
......
......@@ -71,6 +71,9 @@ func linkarchinit() {
ld.Thearch.Lput = ld.Lputl
ld.Thearch.Wput = ld.Wputl
ld.Thearch.Vput = ld.Vputl
ld.Thearch.Append16 = ld.Append16l
ld.Thearch.Append32 = ld.Append32l
ld.Thearch.Append64 = ld.Append64l
ld.Thearch.Linuxdynld = "/lib/ld-linux.so.2"
ld.Thearch.Freebsddynld = "/usr/libexec/ld-elf.so.1"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment