Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # this script must be called 'as'
- # run gcc with option -B<dir of this script> to get it invoked automatically
- lastarg() {
- shift $(($# - 1))
- echo "$1"
- }
- # instead of a jmp, push the address and return
- sed -r -i -e 's/^\tjmpq?\t[*](.*)$/\tpush \1;\tretq/' $(lastarg $@)
- # instead of a ret, do a manual pop and jmp (clobbering a scratch register)
- sed -r -i -e 's/^\t(rep )?ret$/\tpop %rsi;\tjmp *%rsi/' $(lastarg $@)
- # instead of a direct call, push return instruction pointer and destination address, then ret
- sed -r -i -e 's/^\tcall\t([^*].*)$/\tpush %rax;\tlea \1(%rip), %rax;\tpush %rax;\tlea 6(%rip), %rax;\txchg 8(%rsp),%rax;\tretq;\t#call\t\1/' $(lastarg $@)
- exec as $@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement