mirror of
https://github.com/golang/go
synced 2024-11-19 20:54:39 -07:00
cmd/objdump: actually accept hex address without "0x" prefix.
Fixes #7936. LGTM=alex.brainman, bradfitz, iant R=golang-codereviews, alex.brainman, bradfitz, iant CC=golang-codereviews https://golang.org/cl/100060043
This commit is contained in:
parent
f5a4d241cd
commit
5139293986
@ -10,7 +10,7 @@
|
|||||||
//
|
//
|
||||||
// Objdump disassembles the binary starting at the start address and
|
// Objdump disassembles the binary starting at the start address and
|
||||||
// stopping at the end address. The start and end addresses are program
|
// stopping at the end address. The start and end addresses are program
|
||||||
// counters written in hexadecimal without a leading 0x prefix.
|
// counters written in hexadecimal with optional leading 0x prefix.
|
||||||
//
|
//
|
||||||
// It prints a sequence of stanzas of the form:
|
// It prints a sequence of stanzas of the form:
|
||||||
//
|
//
|
||||||
@ -40,12 +40,13 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func printUsage(w *os.File) {
|
func printUsage(w *os.File) {
|
||||||
fmt.Fprintf(w, "usage: objdump binary start end\n")
|
fmt.Fprintf(w, "usage: objdump binary start end\n")
|
||||||
fmt.Fprintf(w, "disassembles binary from start PC to end PC.\n")
|
fmt.Fprintf(w, "disassembles binary from start PC to end PC.\n")
|
||||||
fmt.Fprintf(w, "start and end are hexadecimal numbers with no 0x prefix.\n")
|
fmt.Fprintf(w, "start and end are hexadecimal numbers with optional leading 0x prefix.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func usage() {
|
func usage() {
|
||||||
@ -79,11 +80,11 @@ func main() {
|
|||||||
log.Fatalf("reading %s: %v", flag.Arg(0), err)
|
log.Fatalf("reading %s: %v", flag.Arg(0), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
start, err := strconv.ParseUint(flag.Arg(1), 0, 64)
|
start, err := strconv.ParseUint(strings.TrimPrefix(flag.Arg(1), "0x"), 16, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("invalid start PC: %v", err)
|
log.Fatalf("invalid start PC: %v", err)
|
||||||
}
|
}
|
||||||
end, err := strconv.ParseUint(flag.Arg(2), 0, 64)
|
end, err := strconv.ParseUint(strings.TrimPrefix(flag.Arg(2), "0x"), 16, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("invalid end PC: %v", err)
|
log.Fatalf("invalid end PC: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user