[LLVMdev] Backend optimizations

Rinaldini Julien julien.rinaldini at heig-vd.ch
Tue Jan 27 09:05:31 PST 2015


> On 1/26/15 9:33 AM, Rinaldini Julien wrote:
>> The goal here is to add some obfuscation to the final binary, so some
>> performance loss is excepted!
> You could solve the unbalanced call/return by replacing the return with
> a pop and jump, but I don't think that's going to fool anybody for long...

Yeah I know, you should not use that alone... But I have some other
stuffs ;)

> But this brings forth an idea: one interesting optimization for for
> internal subroutines that are not internally recursive would be to:
> 
> 1.   Put the return address into a temp.
> 2.  Jump to the entry point (using a PHI instruction to collect the
> arguments).
> 3.  Use a computed branch on the temp instead of return.

It should be possible to do that also I guess.

But actually I have some others problems. I tried to expand the call
like Tim Northover said, but I was not able to make it works. You have
to push the return address and I did not find a solution to add the
future address of the next instruction in the 'push'.

I tried to keep my solution in ISelLowering, so I can create the new
basic block, get the address and push it, add the 'jmp', leave the
normal call so the arguments are not destroyed, and then, in
MCInstLower, everytime there is a call, I detect if my intrinsic is
present and delete the call. But this don't work. Something else reorder
the basic block and it fails at link time because it cannot find the
basic block address :(

Cheers





More information about the llvm-dev mailing list