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

Disassembler not correctly representing negative offsets #214

Closed
Oshawk opened this issue Sep 10, 2021 · 6 comments · Fixed by #215
Closed

Disassembler not correctly representing negative offsets #214

Oshawk opened this issue Sep 10, 2021 · 6 comments · Fixed by #215
Assignees

Comments

@Oshawk
Copy link

Oshawk commented Sep 10, 2021

An instruction such as:

79a6b0ff00000000

Is disassembled to:

ldxdw r6, [r10+0xffb0]

Whereas I believe it should be:

ldxdw r6, [r10-0x50]

It seems like this applies to all instructions involving offsets.

@Oshawk
Copy link
Author

Oshawk commented Sep 16, 2021

lddw is also incorrectly represented. It only takes one imm, not two.

@dmakarov
Copy link
Collaborator

dmakarov commented Sep 16, 2021

I forgot rbpf has its own disassembler. Thanks for reporting these errors.

@dmakarov
Copy link
Collaborator

lddw is also incorrectly represented. It only takes one imm, not two.

I don't see two immediate operands in disassembler output.

@Oshawk
Copy link
Author

Oshawk commented Sep 16, 2021

I mean lddw is the only 16-byte instruction. It takes the imm from two consecutive 8-bytes (see https://github.com/solana-labs/rbpf/blob/main/src/ebpf.rs#L554). The disassembly only takes one imm.

@dmakarov
Copy link
Collaborator

I mean lddw is the only 16-byte instruction. It takes the imm from two consecutive 8-bytes (see https://github.com/solana-labs/rbpf/blob/main/src/ebpf.rs#L554). The disassembly only takes one imm.

yes, it's a 64-bit immediate value, and it is decoded from the 128-bits of the instruction code. There are no two immediates. Not all bits of the 128-bit instruction code are used. Can you give an example of code that was disassembled incorrectly?

@Oshawk
Copy link
Author

Oshawk commented Sep 16, 2021

Wait. Sorry, I'm stupid. I didn't realise that augment_lddw_unchecked had been applied prior to disassemble_instruction. I think it disassembles correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants