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

Improve lifting of BEXTR instruction for x86 #6287

Open
SlidyBat opened this issue Dec 30, 2024 · 1 comment
Open

Improve lifting of BEXTR instruction for x86 #6287

SlidyBat opened this issue Dec 30, 2024 · 1 comment
Assignees
Labels
Arch: x86 Issues with the x86/x64 architecture plugin Component: Architecture Issue needs changes to an architecture plugin Effort: Trivial Issue should take < 1 day Impact: Low Issue is a papercut or has a good, supported workaround Type: Enhancement Issue is a small enhancement to existing functionality

Comments

@SlidyBat
Copy link

What is the feature you'd like to have?
Lifting of the BEXTR instruction is currently handled as an intrinsic.

This produces hard to understand HLIL, and could be improved if it was lifted to a bit-shift/mask instead.

Assembly:

00000000  b902010000         mov     ecx, 0x102
00000005  c4e270f7c7         bextr   eax, edi, ecx
0000000a  c3                 retn

HLIL:

00000000    uint64_t sub_0(int32_t arg1)

00000005        uint64_t rflags
00000005        int32_t temp0
00000005        temp0, rflags = __bextr_gpr32d_gpr32d_gpr32d(arg1, 0x102)
0000000a        return zx.q(temp0)

IDA output:

__int64 __fastcall sub_0(unsigned int a1)
{
  return (a1 >> 2) & 1;
}

Is your feature request related to a problem?
Can replicate above assembly by pasting these bytes:
b902010000c4e270f7c7c3

Are any alternative solutions acceptable?
Separating the start/len of the bextr intrinsic into 2 separate arguments (and making intrinsic name shorter) could make it more readable, but bit-shift/mask would be best.

@xusheng6 xusheng6 added Type: Enhancement Issue is a small enhancement to existing functionality Component: Architecture Issue needs changes to an architecture plugin Arch: x86 Issues with the x86/x64 architecture plugin Impact: Low Issue is a papercut or has a good, supported workaround Effort: Low Issue should take < 1 week labels Jan 6, 2025
@xusheng6
Copy link
Member

xusheng6 commented Jan 6, 2025

This is a very reasonable feature request! However, we are unlikely to deal with it very soon since the x86 instrinsics are all generated from xed instead of hand-rolled

@plafosse plafosse added Effort: Trivial Issue should take < 1 day and removed Effort: Low Issue should take < 1 week labels Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: x86 Issues with the x86/x64 architecture plugin Component: Architecture Issue needs changes to an architecture plugin Effort: Trivial Issue should take < 1 day Impact: Low Issue is a papercut or has a good, supported workaround Type: Enhancement Issue is a small enhancement to existing functionality
Projects
None yet
Development

No branches or pull requests

4 participants