Re: regarding process segment in kernel

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

 



Hi,

Le Thu, 17 Aug 2006 12:49:51 +0530,
"suman adak" <gnusuman@xxxxxxxxx> a écrit :

> i have some doubt about process segment in linux kernel. I wrote a
> small program. I tried to see which segment falls in which virtual
> address space. i do it like
> suman@ajit process_info]$ size -x ./process_plain
>    text    data     bss     dec     hex filename
>   0x485   0x10c     0x8    1433     599 ./process_plain
> 
> ..one doubt why size is not showing "stack" segment.....

You're confusing two different things:

 *) _sections_, which are portions of a binary file, such
    as .text, .data, .rodata, .bss, .rel.text, etc.

 *) _VMA_, which are portions of an address space

The exec() system call "loads" a binary by mapping some of its sections
into the current address space under the form of VMAs.

Only some of the sections are mapped, the one that are needed to run
the binary: .text, .data and .rodata, mainly. Most of the other sections
of a binary (.dynsym, .dynstr, and others) are not needed during the
execution of the program itself.

So, you don't see a stack section in your binary because it doesn't
make sense: the stack is a dynamic thing. It doesn't make sense to
store the stack in the binary file.

> i got wonder when i saw the output with objdump -h ./process_plain
> and later size -A -x ./process_plain. I could see that the result
> contains 23 segments... i checked with these segments by writing
> kernel module which list the VMA. (by manipulating memory data
> structure mm_struct,vm_area_struct,task_struct). I saw that it also
> lists 23 VMA.

It's certainly a coincidence: the binary and the shared libraries used
by the binary are mapped in the address space, that's why you're seing
23 VMAs. But it has nothing to do with the 23 sections of your binary.

Moreover, to list VMAs, a simpler way is to "cat /proc/[PID]/maps".
This is much simpler than using a dedicated kernel module.

Sincerly,

Thomas
-- 
Thomas Petazzoni - thomas.petazzoni@xxxxxxxx
http://{thomas,sos,kos}.enix.org - http://www.toulibre.org
http://www.{livret,agenda}dulibre.org

--
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