Useful x86 assembly instruction that basically "calls" the next opcode as a subroutine, thus causing the current address to be pushed onto the stack.

The next instruction would likely be a "pop ebx" or "pop ebp", causing ebx or ebp to contain the address of that instruction. Used cleverly, you can now make your code totally position-independent, by offseting all addresses with ebx (or ebp). (of course, you have now "wasted" a precious register)

Very often seen in computer viruses, since many of these must be able to attach to a target host on (at compile-time) unknown addresses. I also believe that the FreeBSD a.out shared libraries use something to this effect. On a wild guess, GCC has an option -fPIC which perhaps does something like this?

Log in or register to write something here or to contact authors.