aboutsummaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-10-05 10:06:30 -0400
committerRuss Cox <rsc@golang.org>2017-10-05 17:39:35 +0000
commitd24a36cc4caf51c88082c9b17201b6088b9bfc86 (patch)
tree3c064e6084c0cc2c62c20897d2a7d2dc8470bd54 /src/debug
parent8ec188975b5541df3e6b4aae25dadfca20c31d37 (diff)
downloadgo-d24a36cc4caf51c88082c9b17201b6088b9bfc86.tar.xz
debug/elf: make safe for Go 1.4 compilers
We're going to start building cmd/cgo as part of the bootstrap, and with it debug/elf, so the copy here needs to work with Go 1.4. It does except for the use of the new io.SeekStart etc constants, so remove that use. Change-Id: Ib7fcf46e1e9060f96d2bacaaf349c9b0df347550 Reviewed-on: https://go-review.googlesource.com/68337 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/elf/file.go19
-rw-r--r--src/debug/elf/reader.go6
2 files changed, 18 insertions, 7 deletions
diff --git a/src/debug/elf/file.go b/src/debug/elf/file.go
index 8eeab65df8..95c0606f80 100644
--- a/src/debug/elf/file.go
+++ b/src/debug/elf/file.go
@@ -17,6 +17,17 @@ import (
"strings"
)
+// seekStart, seekCurrent, seekEnd are copies of
+// io.SeekStart, io.SeekCurrent, and io.SeekEnd.
+// We can't use the ones from package io because
+// we want this code to build with Go 1.4 during
+// cmd/dist bootstrap.
+const (
+ seekStart int = 0
+ seekCurrent int = 1
+ seekEnd int = 2
+)
+
// TODO: error reporting detail
/*
@@ -269,7 +280,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
switch f.Class {
case ELFCLASS32:
hdr := new(Header32)
- sr.Seek(0, io.SeekStart)
+ sr.Seek(0, seekStart)
if err := binary.Read(sr, f.ByteOrder, hdr); err != nil {
return nil, err
}
@@ -288,7 +299,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
shstrndx = int(hdr.Shstrndx)
case ELFCLASS64:
hdr := new(Header64)
- sr.Seek(0, io.SeekStart)
+ sr.Seek(0, seekStart)
if err := binary.Read(sr, f.ByteOrder, hdr); err != nil {
return nil, err
}
@@ -315,7 +326,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
f.Progs = make([]*Prog, phnum)
for i := 0; i < phnum; i++ {
off := phoff + int64(i)*int64(phentsize)
- sr.Seek(off, io.SeekStart)
+ sr.Seek(off, seekStart)
p := new(Prog)
switch f.Class {
case ELFCLASS32:
@@ -359,7 +370,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
names := make([]uint32, shnum)
for i := 0; i < shnum; i++ {
off := shoff + int64(i)*int64(shentsize)
- sr.Seek(off, io.SeekStart)
+ sr.Seek(off, seekStart)
s := new(Section)
switch f.Class {
case ELFCLASS32:
diff --git a/src/debug/elf/reader.go b/src/debug/elf/reader.go
index eab437318d..a45843619e 100644
--- a/src/debug/elf/reader.go
+++ b/src/debug/elf/reader.go
@@ -63,11 +63,11 @@ func (r *readSeekerFromReader) Read(p []byte) (n int, err error) {
func (r *readSeekerFromReader) Seek(offset int64, whence int) (int64, error) {
var newOffset int64
switch whence {
- case io.SeekStart:
+ case seekStart:
newOffset = offset
- case io.SeekCurrent:
+ case seekCurrent:
newOffset = r.offset + offset
- case io.SeekEnd:
+ case seekEnd:
newOffset = r.size + offset
default:
return 0, os.ErrInvalid