linker - Is there anyway to force loader to load shared library at a fixed address? -


i have own shared library doing low level. needs know it's loaded start address @ compile time.

is there anyway force loader load shared library @ fixed address?

# create linker script  $ export base_address=0x00800000 $ gcc -shared -wl,--verbose 2>&1 | sed -e '/^======/,/^======/!d' -e '/^======/d;s/0\(.*\)\(+ sizeof_headers\)/'$base_address'\1\2/' >foo.lds  # build , link linker-script  $ gcc -shared foo.c -o foo.o $ gcc -wl,-t,foo.lds -shared -fpic foo.o -o foo.so $ objdump --syms foo.so   foo.so:     file format elf32-i386  symbol table:  00800114 l    d  .note.gnu.build-id 00000000              .note.gnu.build-id 00800138 l    d  .gnu.hash  00000000              .gnu.hash 0080016c l    d  .dynsym    00000000              .dynsym 008001fc l    d  .dynstr    00000000              .dynstr ... 

Comments