LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-30-2008, 03:46 PM   #1
ddenisen
LQ Newbie
 
Registered: Oct 2008
Distribution: CentOS
Posts: 3

Rep: Reputation: 0
What's the purpose of the extra virtual memory overhead for 64-bit libraries?


I noticed that every 64-bit library reserves either 1 or 2 MB of virtual memory. Here's an example snipped of "pmap <pid>" output (the interesting line has permissions "-----"):

0000003341800000 532K r-x-- /lib64/tls/libm-2.3.4.so
0000003341885000 1020K ----- /lib64/tls/libm-2.3.4.so
0000003341984000 4K r---- /lib64/tls/libm-2.3.4.so
0000003341985000 4K rw--- /lib64/tls/libm-2.3.4.so

32-bit libraries do not have this overhead. This memory does not seem to be backed by physical RAM (VmRSS number in /proc/<pid>/status is too small to include these overheads) and hence doesn't seem to be a problem. I'm still curious what that extra space is for. Does anybody know?

In case this matters, I'm using CentOS 4.6 with kernel 2.6.9-67 on x86-64 CPU.


Thank you.

Last edited by ddenisen; 10-30-2008 at 03:50 PM.
 
Old 10-31-2008, 12:51 AM   #2
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 666

Rep: Reputation: 133Reputation: 133
Could you post output of
Code:
readelf -l /lib64/tls/libm-2.3.4.so
?
 
Old 10-31-2008, 08:59 AM   #3
ddenisen
LQ Newbie
 
Registered: Oct 2008
Distribution: CentOS
Posts: 3

Original Poster
Rep: Reputation: 0
<Didn't use CODE tags around the output so the post was incomprehensible. Removed it>

Last edited by ddenisen; 10-31-2008 at 09:03 AM. Reason: Didn't use code tags
 
Old 10-31-2008, 09:02 AM   #4
ddenisen
LQ Newbie
 
Registered: Oct 2008
Distribution: CentOS
Posts: 3

Original Poster
Rep: Reputation: 0
That came out ugly. Let me try again:

Code:
> readelf -l /lib64/tls/libm-2.3.4.so

Elf file type is DYN (Shared object file)
Entry point 0x3341803df0
There are 9 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000003341800040 0x0000003341800040
                 0x00000000000001f8 0x00000000000001f8  R E    8
  INTERP         0x0000000000080570 0x0000003341880570 0x0000003341880570
                 0x000000000000001c 0x000000000000001c  R      10
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
  LOAD           0x0000000000000000 0x0000003341800000 0x0000003341800000
                 0x000000000008459c 0x000000000008459c  R E    100000
  LOAD           0x0000000000084dc8 0x0000003341984dc8 0x0000003341984dc8
                 0x00000000000003b8 0x0000000000000400  RW     100000
  DYNAMIC        0x0000000000084df0 0x0000003341984df0 0x0000003341984df0
                 0x00000000000001b0 0x00000000000001b0  RW     8
  NOTE           0x0000000000000238 0x0000003341800238 0x0000003341800238
                 0x0000000000000020 0x0000000000000020  R      4
  GNU_EH_FRAME   0x000000000008058c 0x000000334188058c 0x000000334188058c
                 0x0000000000000dfc 0x0000000000000dfc  R      4
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     8
  GNU_RELRO      0x0000000000084dc8 0x0000003341984dc8 0x0000003341984dc8
                 0x0000000000000238 0x0000000000000238  R      1

 Section to Segment mapping:
  Segment Sections...
   00
   01     .interp
   02     .note.ABI-tag .hash .dynsym .dynstr .gnu.version .gnu.version_d .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .interp .eh_frame_hdr .eh_frame
   03     .ctors .dtors .jcr .dynamic .got .got.plt .data .bss
   04     .dynamic
   05     .note.ABI-tag
   06     .eh_frame_hdr
   07
   08     .ctors .dtors .jcr .dynamic .got

Last edited by ddenisen; 10-31-2008 at 09:03 AM.
 
Old 11-05-2008, 03:39 AM   #5
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 666

Rep: Reputation: 133Reputation: 133
Quote:
Originally Posted by ddenisen View Post
That came out ugly. Let me try again:

Code:
> readelf -l /lib64/tls/libm-2.3.4.so

Elf file type is DYN (Shared object file)
Entry point 0x3341803df0
There are 9 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000003341800040 0x0000003341800040
                 0x00000000000001f8 0x00000000000001f8  R E    8
  INTERP         0x0000000000080570 0x0000003341880570 0x0000003341880570
                 0x000000000000001c 0x000000000000001c  R      10
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
  LOAD           0x0000000000000000 0x0000003341800000 0x0000003341800000
                 0x000000000008459c 0x000000000008459c  R E    100000
  LOAD           0x0000000000084dc8 0x0000003341984dc8 0x0000003341984dc8
                 0x00000000000003b8 0x0000000000000400  RW     100000
  DYNAMIC        0x0000000000084df0 0x0000003341984df0 0x0000003341984df0
                 0x00000000000001b0 0x00000000000001b0  RW     8
  NOTE           0x0000000000000238 0x0000003341800238 0x0000003341800238
                 0x0000000000000020 0x0000000000000020  R      4
  GNU_EH_FRAME   0x000000000008058c 0x000000334188058c 0x000000334188058c
                 0x0000000000000dfc 0x0000000000000dfc  R      4
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     8
  GNU_RELRO      0x0000000000084dc8 0x0000003341984dc8 0x0000003341984dc8
                 0x0000000000000238 0x0000000000000238  R      1

 Section to Segment mapping:
  Segment Sections...
   00
   01     .interp
   02     .note.ABI-tag .hash .dynsym .dynstr .gnu.version .gnu.version_d .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .interp .eh_frame_hdr .eh_frame
   03     .ctors .dtors .jcr .dynamic .got .got.plt .data .bss
   04     .dynamic
   05     .note.ABI-tag
   06     .eh_frame_hdr
   07
   08     .ctors .dtors .jcr .dynamic .got
ld-linux working as following:
1) map ALL PT_LOAD segments at ONCE (with permission of first PT_LOAD segment)
2) walk PT_LOAD segment list and change (with mprotect) segment's permission to correct ones. That include changing 'hole' permissions to 0

PT_LOAD segments alignment on x86_64 is 0x100000. PAGE_SIZE is 0x1000
(Why alignment is 0x100000 is beyond me.)
When ld-linux decide where first segment ended it uses PAGE_SIZE. But when linker select virtual address for the second PT_LOAD segments it used alignment (i.e 0x100000) So from the loader's point of view there is a hole between first and second PT_LOAD segment, and you saw it as mapping with '---' permissions.

On the x86 both alignment and PAGE_SIZE are 0x1000 so there is no dummy mappings there.
 
  


Reply

Tags
library, memory, virtual


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto install 32-bit libraries on 64-bit Linux using yum shawn_t Linux - Server 16 07-13-2012 02:46 AM
64-bit Linux virtual memory limit? wmnwmn Linux - General 1 02-01-2008 10:43 AM
Difference between resident memory,shared memory and virtual memory in system monitor mathimca05 Linux - Newbie 1 11-11-2007 04:05 AM
how do I install 32-bit compiler libraries onto a 64-bit machine? charleycat Linux - Software 1 08-16-2007 01:45 PM
Best Way to Get at Extra Bit of High Memory? IamI Slackware 4 04-21-2005 11:04 PM


All times are GMT -5. The time now is 05:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration