What is the output of objdump?

531 views
Skip to first unread message

buch...@gmail.com

unread,
Feb 27, 2020, 10:03:35 PM2/27/20
to golang-nuts
Can someone please explain the columns printed by "go tool objdump"?

For example:

TEXT %22%22.main(SB) gofile../Users/abuchanan/projects/gobuild/simple/main.go
  main
.go:3        0x2db            65488b0c2500000000    MOVQ GS:0, CX        [5:9]R_TLS_LE
  main
.go:3        0x2e4            483b6110        CMPQ 0x10(CX), SP
  main
.go:3        0x2e8            763b            JBE 0x325
  main
.go:3        0x2ea            4883ec18        SUBQ $0x18, SP
  main
.go:3        0x2ee            48896c2410        MOVQ BP, 0x10(SP)
  main
.go:3        0x2f3            488d6c2410        LEAQ 0x10(SP), BP
  main
.go:4        0x2f8            e800000000        CALL 0x2fd        [1:5]R_CALL:runtime.printlock
  main
.go:4        0x2fd            488d0500000000        LEAQ 0(IP), AX        [3:7]R_PCREL:go.string."main"
  main
.go:4        0x304            48890424        MOVQ AX, 0(SP)
  main
.go:4        0x308            48c744240804000000    MOVQ $0x4, 0x8(SP)
  main
.go:4        0x311            e800000000        CALL 0x316        [1:5]R_CALL:runtime.printstring
  main
.go:4        0x316            e800000000        CALL 0x31b        [1:5]R_CALL:runtime.printunlock
  main
.go:5        0x31b            488b6c2410        MOVQ 0x10(SP), BP
  main
.go:5        0x320            4883c418        ADDQ $0x18, SP
  main
.go:5        0x324            c3            RET
  main
.go:3        0x325            e800000000        CALL 0x32a        [1:5]R_CALL:runtime.morestack_noctxt
  main
.go:3        0x32a            ebaf            JMP %22%22.main(SB)

Column 1 is the source file + line. Column 4 is the machine code instruction. I'm not sure what columns 2, 3, and 5 are. Also not sure what the "TEXT %22%22.main(SB) gofile../Users/abuchanan/projects/gobuild/simple/main.go" line is.

Thanks.

wagner riffel

unread,
Feb 28, 2020, 12:13:29 AM2/28/20
to buch...@gmail.com, golang-nuts
On Thu, 27 Feb 2020 19:03:02 -0800 (PST)
buch...@gmail.com wrote:

> Can someone please explain the columns printed by "go tool objdump"?
> instruction. I'm not sure what columns 2, 3, and 5 are.

Column $2 is the memory address offset, $3 is the entire instruction
encoded in hexadecimal, $5 is a continuation of $4, a disassembled
version of $3

> what the "TEXT %22%22.main(SB)
> gofile../Users/abuchanan/projects/gobuild/simple/ main.go" line is.

TEXT is a pseudo-operation to the "entry point" to the function,
%22%22.main(SB) is the function label itself.

You can find reference only here:
https://golang.org/doc/asm
https://9p.io/sys/doc/asm.html

—wagner

ohm patel

unread,
Jan 16, 2025, 1:58:12 PMJan 16
to golang-nuts
How can I get just the hex of opcode from the $3 which is the entire instruction
encoded in hexadecimal?
Reply all
Reply to author
Forward
0 new messages