<< 33/55 >>
First Last

Relocation

We bind symbols in Linux to addresses in Mac binary

We can just use dlsym

% dyldinfo -lazy_bind hello_world

  lazy binding information (from lazy_bind part of dyld info):
  segment section          address    index  dylib            symbol
  __DATA  __la_symbol_ptr  0x100001038 0x0000 libSystem        _exit
  __DATA  __la_symbol_ptr  0x100001040 0x000C libSystem        _puts

This hello_world works only with the following relocations:

 *(void**)0x100001038 = dlsym(RTLD_DEFAULT, "exit");
 *(void**)0x100001040 = dlsym(RTLD_DEFAULT, "puts");

This works because they use the same ABI

http://www.x86-64.org/documentation/abi.pdf