This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/214] sbrk() doesn't detect brk() failures. Malloc doesn't handle sbrk() failures
- From: "rsa at us dot ibm dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 13 Mar 2006 16:24:25 -0000
- Subject: [Bug libc/214] sbrk() doesn't detect brk() failures. Malloc doesn't handle sbrk() failures
- References: <20040610193839.214.dlstevens@us.ibm.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From rsa at us dot ibm dot com 2006-03-13 16:24 -------
Thanks to Alan Modra for the following explanation of how ld locates the data in
memory:
ld tries to optimize memory and disk usage for the executable.
Consider a small executable laid out like the following:
______________________
| text | data |
~~~~~~~~~~~~~~~~~~~~~~
^ ^ ^
|- page boundaries
This will require two disk pages, and three memory pages,
one for text and two for data (demand paging requires that
vma and file offset are equal modulo page size, protection
requirements mean text and data must be on separate pages).
The same executable laid out like this:
____________________________
| text | gap | data |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^ ^ ^
|- page boundaries
still requires two disk pages, but now only two memory pages.
Sometimes adjusting the data start as above doesn't gain us
anything in memory and increases disk image, so ld doesn't
adjust.
See ld info DATA_SEGMENT_ALIGN.
--
http://sourceware.org/bugzilla/show_bug.cgi?id=214
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.