user2628063
user2628063

Reputation: 21

Using deprecated x86_32 instructions in 64 bit mode

Not sure whether this is a dumb question or there is a clever trick involved here.

I want to use x86_32 'into' ( exception on int overflow ) instruction for a debugger I am writing for fun. I see this instruction was never really mainstream and got deprecated in x86_64. I want to perform int overflow checks in my program at runtime ( I am building this functionality on top of a dynamic binary instrumentation framework ) for x86_64.

  1. Is there any way to use this instruction for bounds checking on x86_64 by using some trick ?

  2. I dont have liberty to recompile programs so all compiler related flags are ruled out. I have infrastructure to generate runtime code though.

  3. I don't want to implement this bounds checking in software ( I have my own reasons ) and want to leverage hw features.

NOTE: I am aware of new Intel MPX instructions which can be used for bounds checking, but these are not widespread yet.

Any thoughts ?

Upvotes: 2

Views: 832

Answers (1)

Johan
Johan

Reputation: 76703

INTO in x64 is deprecated.
This is a good thing, lots more instructions (e.g. all of x87) should have been deprecated but sadly have not.

Ever since the first 8086 and even before integer overflow has been handled in the Flags register.

Bounds checking for signed values is done using the OF flag, Bounds checking for unsigned values using the C flag.

With all the access violation checking built into the system there is no need to INTO anymore. Your best bet is a write an exception handler.
Maybe ask a question like: "how to catch an exception in x86_64 assembly"?

Upvotes: 1

Related Questions