diff options
author | Shenghou Ma <minux.ma@gmail.com> | 2014-05-08 01:25:56 -0400 |
---|---|---|
committer | Shenghou Ma <minux.ma@gmail.com> | 2014-05-08 01:25:56 -0400 |
commit | 3908d605fec90519e9d9afc5bb481d7687b55e30 (patch) | |
tree | dd2e8312b9db837728e48c59495c7b1b70e0dc7f /src/cmd | |
parent | 82a9e929ef412646fe91c806044989a2c67f6102 (diff) | |
download | go-3908d605fec90519e9d9afc5bb481d7687b55e30.tar.gz |
cmd/objdump: actually accept hex address without "0x" prefix.
Fixes issue 7936.
LGTM=alex.brainman, bradfitz, iant
R=golang-codereviews, alex.brainman, bradfitz, iant
CC=golang-codereviews
https://codereview.appspot.com/100060043
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/objdump/main.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cmd/objdump/main.go b/src/cmd/objdump/main.go index 6efdde214..5602f17d6 100644 --- a/src/cmd/objdump/main.go +++ b/src/cmd/objdump/main.go @@ -10,7 +10,7 @@ // // Objdump disassembles the binary starting at the start address and // 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: // @@ -40,12 +40,13 @@ import ( "log" "os" "strconv" + "strings" ) func printUsage(w *os.File) { fmt.Fprintf(w, "usage: objdump binary start end\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() { @@ -79,11 +80,11 @@ func main() { 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 { 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 { log.Fatalf("invalid end PC: %v", err) } |