The commands
gcc main.c -o main
ldd main
yield
linux-gate.so.1 => (0x00f67000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0x00b7d000)
/lib/ld-linux.so.2 (0x00ae5000)
Is it possible to change the address where libc.so.6 will be mapped in memory? For example, have libc.so.6 instead be mapped at, say, 0xb0000000.
I’m running Xubuntu 32bit: Linux 3.2.0-23-generic i686 i686 i386 GNU/Linux
There is an
prelinkutility (wiki page) which is capable of changing loading address (it is called "base address") of so libs.There is some info about how prelink works: http://www.acsu.buffalo.edu/~charngda/elf.html
According to
man prelinkthere is an option of prelink utility to rebase (relocate) given library to specified address:The
prelink --reloc-only=0x7896000 libc.so.6should be enough to achieve the change you want.PS: you can do this relocation on your local copy of libc and then give the path to it via
export LD_LIBRARY_PATH=/path/to/your/rebased/copy:$LD_LIBRARY_PATH