number of sections in core dump are more than the mmaped

1

I am trying to debug a kernel module. I have a piece of code to get the number of maps in a process:

    static int tmp_func(void){
      int count = 0;
      struct mm_struct  *mm = current->mm;
      struct vm_area_struct *map;
      down_read(&mm->mmap_sem);
      /* 1. just counts maps ... */
      for (map = mm->mmap; map ; map = map->vm_next) {
         count ++;
      }
      up_read(&mm->mmap_sem);
      printk("tmp_func,count: %d\n",count);
      return count;
    }

It returns 28. when I check the core dump there are 32 loads:

    (gdb)maintenance info sections
     ....
     Core file:
     file type elf64-x86-64.
     0x00000000->0x00000344 at 0x00000778: note0 READONLY HAS_CONTENTS
     0x00000000->0x000000d8 at 0x000007fc: .reg/22787 HAS_CONTENTS
     0x00000000->0x000000d8 at 0x000007fc: .reg HAS_CONTENTS
     0x00000000->0x00000130 at 0x0000098c: .auxv HAS_CONTENTS
     0x00400000->0x00400000 at 0x00001000: load1 ALLOC READONLY CODE
     0x00600000->0x00601000 at 0x00001000: load2 ALLOC LOAD HAS_CONTENTS
     0x00601000->0x00622000 at 0x00002000: load3 ALLOC LOAD HAS_CONTENTS
     0x390ee00000->0x390ee00000 at 0x00023000: load4 ALLOC READONLY CODE
     0x390f01c000->0x390f01d000 at 0x00023000: load5 ALLOC LOAD READONLY HAS_CONTENTS
     0x390f01d000->0x390f01e000 at 0x00024000: load6 ALLOC LOAD HAS_CONTENTS
     0x390f200000->0x390f200000 at 0x00025000: load7 ALLOC READONLY CODE
     0x390f34e000->0x390f34e000 at 0x00025000: load8 ALLOC READONLY
     0x390f54e000->0x390f552000 at 0x00025000: load9 ALLOC LOAD READONLY HAS_CONTENTS
     0x390f552000->0x390f553000 at 0x00029000: load10 ALLOC LOAD HAS_CONTENTS
     0x390f553000->0x390f558000 at 0x0002a000: load11 ALLOC LOAD HAS_CONTENTS
     0x390f600000->0x390f600000 at 0x0002f000: load12 ALLOC READONLY CODE
     0x390f602000->0x390f602000 at 0x0002f000: load13 ALLOC READONLY
     0x390f802000->0x390f803000 at 0x0002f000: load14 ALLOC LOAD READONLY HAS_CONTENTS
     0x390f803000->0x390f804000 at 0x00030000: load15 ALLOC LOAD HAS_CONTENTS
     0x390fa00000->0x390fa00000 at 0x00031000: load16 ALLOC READONLY CODE
     0x390fa16000->0x390fa16000 at 0x00031000: load17 ALLOC READONLY
     0x390fc15000->0x390fc16000 at 0x00031000: load18 ALLOC LOAD READONLY HAS_CONTENTS
     0x390fc16000->0x390fc17000 at 0x00032000: load19 ALLOC LOAD HAS_CONTENTS
     0x390fc17000->0x390fc1b000 at 0x00033000: load20 ALLOC LOAD HAS_CONTENTS
     0x3912200000->0x3912200000 at 0x00037000: load21 ALLOC READONLY CODE
     0x391220d000->0x391220d000 at 0x00037000: load22 ALLOC READONLY
     0x391240d000->0x391240e000 at 0x00037000: load23 ALLOC LOAD HAS_CONTENTS
     0x2b1df1bef000->0x2b1df1bf1000 at 0x00038000: load24 ALLOC LOAD HAS_CONTENTS
     0x2b1df1bf1000->0x2b1df1bf1000 at 0x0003a000: load25 ALLOC READONLY CODE
     0x2b1df1bfa000->0x2b1df1bfa000 at 0x0003a000: load26 ALLOC READONLY
     0x2b1df1dfa000->0x2b1df1dfb000 at 0x0003a000: load27 ALLOC LOAD HAS_CONTENTS
     0x2b1df1dfb000->0x2b1df1dfd000 at 0x0003b000: load28 ALLOC LOAD HAS_CONTENTS
     0x2b1df1e0f000->0x2b1df1e12000 at 0x0003d000: load29 ALLOC LOAD HAS_CONTENTS
     0x7fff99a35000->0x7fff99a4a000 at 0x00040000: load30 ALLOC LOAD HAS_CONTENTS
     0x7fff99b5e000->0x7fff99b5f000 at 0x00055000: load31 ALLOC LOAD READONLY CODE HAS_CONTENTS
     0xffffffffff600000->0xffffffffff600000 at 0x00056000: load32 ALLOC READONLY CODE

I checked and found out that load 3,21,22,23 are not counted in my code.

I got the full content of all sections. Here:

    load3: has libgcc_s.so.1
    load21 and load22 were not there
    load23: nothing meaningful (seems to be a Hash Section)

I am wondering what could be the reason.

info: x86_64, centos 5.7, 2.6.32, GCC 4.1.2.

[edit: my application here is a for loop with a printf and a sleep]

linux
memory
core
mmap
asked on Stack Overflow Oct 2, 2012 by (unknown user) • edited Oct 2, 2012 by (unknown user)

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0