Hi all,

Does anyone know how to control the address space layout of a
dynamically linked program in linux? Alternatively, are dynamically
linked libraries always going to be in the same place?

E.g: 

When compling a simple hello world program, and running it I end
up with a memory map like so:
cat /proc/1234/maps
08048000-08049000 r-xp 00000000 08:03 33938996   /home/benno/tmp/work/a.out
08049000-0804a000 rw-p 00000000 08:03 33938996   /home/benno/tmp/work/a.out
b7e91000-b7e92000 rw-p b7e91000 00:00 0 
b7e92000-b7e9e000 r-xp 00000000 08:03 117442181  /lib/tls/libpthread-0.60.so
b7e9e000-b7e9f000 rw-p 0000c000 08:03 117442181  /lib/tls/libpthread-0.60.so
b7e9f000-b7ea1000 rw-p b7e9f000 00:00 0 
b7ea1000-b7fca000 r-xp 00000000 08:03 117442168  /lib/tls/libc-2.3.2.so
b7fca000-b7fd2000 rw-p 00129000 08:03 117442168  /lib/tls/libc-2.3.2.so
b7fd2000-b7fd6000 rw-p b7fd2000 00:00 0 
b7fd6000-b7fdb000 r-xp 00000000 08:03 117442183  /lib/tls/librt-2.3.2.so
b7fdb000-b7fdc000 rw-p 00005000 08:03 117442183  /lib/tls/librt-2.3.2.so
b7fe8000-b7fea000 rw-p b7fe8000 00:00 0 
b7fea000-b8000000 r-xp 00000000 08:03 67136311   /lib/ld-2.3.2.so
b8000000-b8001000 rw-p 00015000 08:03 67136311   /lib/ld-2.3.2.so
bfffe000-c0000000 rw-p bfffe000 00:00 0 
ffffe000-fffff000 ---p 00000000 00:00 0 

The same program linked statically gives:
08048000-080ad000 r-xp 00000000 08:03 33938996   /home/benno/tmp/work/a.out
080ad000-080af000 rw-p 00064000 08:03 33938996   /home/benno/tmp/work/a.out
080af000-080d1000 rw-p 080af000 00:00 0 
b7fff000-b8000000 rw-p b7fff000 00:00 0 
bffff000-c0000000 rw-p bffff000 00:00 0 
ffffe000-fffff000 ---p 00000000 00:00 0 

It would be convenient for my current project if there was some way
to specify where in VM the dynamic libraries ended up. 

Along the same line, is there a way to control the location of stack and heap?

(I'm not at all certain that this can actually be done, and I'll probably have 
to 
use a staticly linked library.)

Cheers,

Benno
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to