Commit a697c4b4 authored by Russ Cox's avatar Russ Cox

cmd/internal/objfile: minor edits

Follow-up in response to comments on
TBR'ed CL 171260043.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/172080043
parent 2ad99f09
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package objfile package objfile
import ( import (
...@@ -17,14 +21,14 @@ import ( ...@@ -17,14 +21,14 @@ import (
// Disasm is a disassembler for a given File. // Disasm is a disassembler for a given File.
type Disasm struct { type Disasm struct {
syms []Sym syms []Sym //symbols in file, sorted by address
pcln *gosym.Table pcln *gosym.Table // pcln table
text []byte text []byte // bytes of text segment (actual instructions)
textStart uint64 textStart uint64 // start PC of text
textEnd uint64 textEnd uint64 // end PC of text
goarch string goarch string // GOARCH string
disasm disasmFunc disasm disasmFunc // disassembler function for goarch
byteOrder binary.ByteOrder byteOrder binary.ByteOrder // byte order for goarch
} }
// Disasm returns a disassembler for the file f. // Disasm returns a disassembler for the file f.
...@@ -89,7 +93,8 @@ func (d *Disasm) lookup(addr uint64) (name string, base uint64) { ...@@ -89,7 +93,8 @@ func (d *Disasm) lookup(addr uint64) (name string, base uint64) {
} }
// base returns the final element in the path. // base returns the final element in the path.
// It works on both Windows and Unix paths. // It works on both Windows and Unix paths,
// regardless of host operating system.
func base(path string) string { func base(path string) string {
path = path[strings.LastIndex(path, "/")+1:] path = path[strings.LastIndex(path, "/")+1:]
path = path[strings.LastIndex(path, `\`)+1:] path = path[strings.LastIndex(path, `\`)+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