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

x/arch/arm64/arm64asm: all fields of potential Args structs should be exported #51407

Closed
fabled opened this issue Mar 1, 2022 · 4 comments
Closed
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@fabled
Copy link

fabled commented Mar 1, 2022

What version of Go are you using (go version)?

$ go version
go1.17.7

Does this issue reproduce with the latest release?

Yes.

What did you do?

I would like to programmatically access all fields of the arm64 disassembler Instruction Args.

	code := []byte{0x01,0xd4,0x43,0xf9} // LDR X1, [X0,#1960]
	inst, _ := arm64asm.Decode(code)
	fmt.Printf("opcode: %#v\n", inst)
	// arm64asm.Inst{Op:0xb1, Enc:0xf943d401,
	//	Args:arm64asm.Args{0x21, arm64asm.MemImmediate{Base:0x20, Mode:0x3, imm:1960},
	//	arm64asm.Arg(nil), arm64asm.Arg(nil), arm64asm.Arg(nil)}}

	// like to extract the offset
	arg := inst.Args[1].(arm64asm.MemImmediate)
	fmt.Printf("argument: %#v\n", arg)
	// arm64asm.MemImmediate{Base:0x20, Mode:0x3, imm:1960}
	//fmt.Printf("offset: %x\n", arg.imm) // error: "cannot refer to unexported field or method imm"

What did you expect to see?

To be able to access programmatically instruction arguments. This would be consistent with the other disassemblers: x86, arm32 and ppc. All of them have all Args field exported (or be typedef to a basic type). It seems arm64 is the only exception where some fields are not exported.

What did you see instead?

Build error, as several fields are unexported.

@gopherbot gopherbot added this to the Unreleased milestone Mar 1, 2022
@gopherbot
Copy link

Change https://go.dev/cl/388714 mentions this issue: arm64/arm64asm: export disassembler Args fields

@cherrymui
Copy link
Member

Public API addition needs to through the proposal process (https://golang.org/s/proposal), including golang.org/x repositories. Please file a proposal (or modify this issue to a proposal). In particular, explain how the new API will be used, with examples. Thanks.

@cherrymui cherrymui added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 1, 2022
@fabled
Copy link
Author

fabled commented Mar 4, 2022

@cherrymui I have updated the issue description with code example and rationale. I do not have the permission to add the proposal label. Please add that, and remove the WaitingForInfo label. Thank you!

@fabled
Copy link
Author

fabled commented Mar 7, 2022

Created new issue #51517 as proposal.

@fabled fabled closed this as completed Mar 7, 2022
@golang golang locked and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants