Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/objdump: output is not valid assembly input #21690

Closed
mc-robin opened this issue Aug 30, 2017 · 1 comment
Closed

cmd/objdump: output is not valid assembly input #21690

mc-robin opened this issue Aug 30, 2017 · 1 comment
Milestone

Comments

@mc-robin
Copy link

I wrote a simple go package as follows:

package mytest

type T int32

func (a T) MyTest(b T) (T, T)
func (p *T) MyTestp(b T) (T, T)
func MyTest(a, b T) (T, T)
func MyTestp(p *T, b T) (T, T)

The corresponding assembly code(generaged by go tool objdump), as follows:

TEXT ·MyTest(SB), $0-16
MOVL a + 0x0(FP), AX
MOVL b + 0x4(FP), BX
MOVL BX, CX
ADDL AX, CX
MOVL CX, r1 + 0x8(FP)
SUBL BX, AX
MOVL AX, r2 + 0xc(FP)
RET

TEXT ·MyTestp(SB), $0-24
MOVQ p + 0x0(FP), CX
MOVL b + 0x8(FP), BX
MOVL (CX), AX
MOVL BX, CX
ADDL AX, CX
MOVL CX, r1 + 0x10(FP)
SUBL BX, AX
MOVL AX, r2 + 0x14(FP)
RET

TEXT ·T·MyTest(SB), $0-16
MOVL a + 0x0(FP), AX
MOVL b + 0x4(FP), BX
MOVL BX, CX
ADDL AX, CX
MOVL CX, r1 + 0x8(FP)
SUBL BX, AX
MOVL AX, r2 + 0xc(FP)
RET

TEXT ·(*T)·MyTestp(SB), $0-24
MOVQ p + 0x0(FP), CX
MOVL b + 0x8(FP), BX
MOVL (CX), AX
MOVL BX, CX
ADDL AX, CX
MOVL CX, r1 + 0xC(FP)
SUBL BX, AX
MOVL AX, r2 + 0x10(FP)
RET

when I compile these assembly code, all is ok except "TEXT
·(*T)·MyTestp(SB), $0-24", error message as follows:

expected identifier, found *

I think objdump using a readable denotion (*T) for output, but for
complier, it is wrong. so do any one know the correct denotion? Thanks in
advance!

@robpike robpike changed the title underline implement of golang method using golang assembly language cmd/objdump: output is not valid assembly input Aug 30, 2017
@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Aug 30, 2017
@rsc
Copy link
Contributor

rsc commented Nov 22, 2017

It is not a guarantee that objdump output or even compiler output is valid assembly. Even if that assembly were accepted the result would not be a working Go program because it would be missing all the type and method tables.

I think this is basically working as intended.

@rsc rsc closed this as completed Nov 22, 2017
@golang golang locked and limited conversation to collaborators Nov 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants