Prev Next Secure Lazy Binding Slide #9

amd64 Example

      extern int foo;
      extern int bar(int);
      int call_bar(void) {
         return bar(foo);
      }
      movq    foo@GOTPCREL(%rip), %rax  # load foo's address from GOT
      movl    (%rax), %edi              # read foo's value
      call    bar@PLT                   # call bar's PLT stub
      .PLT0: pushq   GOT+8(%rip)         # push argument for lazy bind code
             jmp     *GOT+16(%rip)       # jump to lazy binding entry
             ....
      .PLTn: jmp     *bar@GOTPCREL(%rip) # load address from JUMP_SLOT in GOT
             pushq   $index1             # load index of JUMP_SLOT relocation
             jmp     .PLT0               # jump to above


EuroBSDCon 2014 Copyright © 2014 Philip Guenther