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

bnd jne instruction #955

Open
Levimocun opened this issue Jul 6, 2017 · 10 comments
Open

bnd jne instruction #955

Levimocun opened this issue Jul 6, 2017 · 10 comments
Labels
X86 Arch

Comments

@Levimocun
Copy link

I use IDA and capstone to disassemble a PE file. But there's a difference, which is bnd jne in capstone but repne jnz short in IDA. Would you please tell the reason?

@aquynh
Copy link
Collaborator

aquynh commented Jul 6, 2017 via email

@Levimocun
Copy link
Author

@aquynh
the result disassembled by capstone
0x1400010a0: cmp rcx, qword ptr [rip + 0x1f61]
0x1400010a7: bnd jne 0x1400010bc
0x1400010aa: rol rcx, 0x10
0x1400010ae: test cx, 0xffff
0x1400010b3: bnd jne 0x1400010b8
0x1400010b6: bnd ret

the result disassembled by IDA
.text:00000001400010A0 cmp rcx, cs:__security_cookie .
text:00000001400010A7 repne jnz short loc_1400010BC
.text:00000001400010AA rol rcx, 10h
.text:00000001400010AE test cx, 0FFFFh
.text:00000001400010B3 repne jnz short loc_1400010B8
.text:00000001400010B6 repne retn

@aquynh
Copy link
Collaborator

aquynh commented Jul 6, 2017

ok, but you havent provided the input code yet: what you gave is only assembly & instruction address.

you can enable Opcode output from menu "Options" -> "General ..." -> "Number of opcode bytes" . You can put 8 in this box, press OK, then paste the output here again.

@Levimocun
Copy link
Author

@aquynh
.text:00000001400010A0--- 48 3B 0D 61 1F 00 00------- cmp rcx, cs:__security_cookie
.text:00000001400010A7--- F2 75 12--------------------- repne jnz short loc_1400010BC
.text:00000001400010AA--- 48 C1 C1 10----------------- rol rcx, 10h
.text:00000001400010AE--- 66 F7 C1 FF FF-------------- test cx, 0FFFFh
.text:00000001400010B3--- F2 75 02-------------------- repne jnz short loc_1400010B8
.text:00000001400010B6--- F2 C3----------------------- repne retn

@aquynh
Copy link
Collaborator

aquynh commented Jul 6, 2017

all jump instructions should not associate with REP prefix, so IDA is confused here.

ping @radare.

@radare
Copy link
Contributor

radare commented Jul 6, 2017 via email

@sanguinawer
Copy link

@aquynh
Copy link
Collaborator

aquynh commented Jul 6, 2017

according to Intel manual, REP prefix is only relevant for string instructions + IN/OUT. it is wrong to have REP with jump instructions.

@fay59
Copy link
Contributor

fay59 commented Jul 6, 2017

Some old AMD CPUs exhibit a branch prediction bug when you have a jump going straight to another jump (or return). Jumping to the rep prefix instead is a workaround for it. Both Intel and AMD CPUs tolerate it without any adverse effects.

@aquynh
Copy link
Collaborator

aquynh commented Jul 7, 2017

yes, but i mean it is better to remove REP in the disassembly output in such a case.

@Rot127 Rot127 added the X86 Arch label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
X86 Arch
Projects
None yet
Development

No branches or pull requests

6 participants