How Can I Get See A Memory Map For An Executable

Ian Lance Taylor ian@airs.com
Tue Nov 15 23:37:00 GMT 2005


Steven Woody <narkewoody@gmail.com> writes:

> >> thank you, but neither of these commands can clearly print size of each segment
> >> ( such as heap, bss, text). but, thanks anyway.
> >
> > The size program will print the size of the text and bss sections.
> >
> > The size of the heap program is determined at runtime.  I do not know
> > of any program which can determine it statically.
> 
> if the heap is not determined statically, how much in size at startup the
> program get the big pool to allocate for each 'new' or 'malloc' calling?

These questions are no longer about gcc, if indeed they ever were.
They are basic Unix questions.  Please take further questions along
these lines to some other mailing list or news group.  Thanks.

Unix systems use virtual memory.  A large chunk of the address space
is available for the heap--all the address space between the end of
the program and the stack.  Any program can theoretically use all of
that space.

Unix programs do not request a certain amount of space when they
start.  They simply request more space as they need it, using the
brk() and sbrk() functions.

> > I don't know where you heard the terms either.  On a typical Unix (or
> > GNU/Linux) system, programs have only one heap.
> 
> at least, for embedded system, the programmer has to specify how much size for
> each kind of heap, NEAR heap, FAR heap, etc.  for Linux, i've not got the
> picture. 

On GNU/Linux there is only one heap, and it is limited primarily by
the size of the address space.

Ian



More information about the Gcc-help mailing list