libraries mapping

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
The segments of shared libraries are not mapped
independently. First all the segments are mapped as a
single VMA(virtual memory area)  calling mmap(). Then
mprotect() is called and this single large region is
broken into text, data, bss regions. 
This happens only with shared libraries. But while
mapping executables and interpreter (dynamic linker)
each segment is mapped one after another.. i.e first
text segment, then data segment and then bss segment.

Why are shared libaries mapped in such differnt way?
Why is mprotect() called??

Lets us see this with an example.
The following is obtained from /proc/1/maps
08048000-0804f000 r-xp 00000000 03:01 29220     
/sbin/init
0804f000-08051000 rw-p 00006000 03:01 29220     
/sbin/init
08051000-08055000 rwxp 00000000 00:00 0
40000000-40015000 r-xp 00000000 03:01 215881    
/lib/ld-2.2.4.so
40015000-40016000 rw-p 00014000 03:01 215881    
/lib/ld-2.2.4.so
40016000-40017000 rw-p 00000000 00:00 0
4002c000-40161000 r-xp 00000000 03:01 217078    
/lib/libc-2.2.4.so
40161000-40166000 rw-p 00134000 03:01 217078    
/lib/libc-2.2.4.so
40166000-4016a000 rw-p 00000000 00:00 0
bfffe000-c0000000 rwxp fffff000 00:00 0

Here the libc library, using mmap(), is mapped into
region from 4002c000-4016a000. Then mprotect is
called. As a result one VMA region form
4002c000-4016a000 is broken into three i.e
4002c000-40161000, 40161000-40166000,
40166000-4016a000.

I you know any URl which explains how libraries are
mapped please let me know.
Thank you in advance,

KR

=====

"Conquering Myselves to Conquer The World"

"Securing Kernel to Secure Whole System"


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux