|
From: Naveen K. <g_n...@ya...> - 2005-03-13 04:37:18
|
Hi,
In mapelf(ume.c) if memsz > filesz we zero out as
follows
bytes = bss & (VKI_BYTES_PER_PAGE - 1);
if (bytes > 0) {
bytes = VKI_BYTES_PER_PAGE - bytes;
memset((char *)bss, 0, bytes);
}
shouldn't we zero it out as
memset((char*)bss, 0, (char*)brkaddr - (char*)bss +
1);
to fill the rest of memsz-filesz bytes ???
The current code was the prime reason stage2 wasn't
loading using the default runtime linker(ld.so) on
solaris-x86. It doesn't seem to make much of a
difference on linux but on solaris it seems critical.
Any thoughts ??
Thanks
Naveen
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
|
|
From: Jeremy F. <je...@go...> - 2005-03-13 08:12:00
|
Naveen Kumar wrote:
>Hi,
> In mapelf(ume.c) if memsz > filesz we zero out as
>follows
>
> bytes = bss & (VKI_BYTES_PER_PAGE - 1);
> if (bytes > 0) {
> bytes = VKI_BYTES_PER_PAGE - bytes;
> memset((char *)bss, 0, bytes);
> }
>
>shouldn't we zero it out as
>
>memset((char*)bss, 0, (char*)brkaddr - (char*)bss +
>1);
>to fill the rest of memsz-filesz bytes ???
>The current code was the prime reason stage2 wasn't
>loading using the default runtime linker(ld.so) on
>solaris-x86. It doesn't seem to make much of a
>difference on linux but on solaris it seems critical.
>Any thoughts ??
>
It shouldn't be necessary to clear out the whole bss. There should be
two mappings: one mmaping the data segment out of the executable, and a
second anonymous (or /dev/zero) mapping for all but the first partial
page of the bss. If the data does not end exacty on a page boundary,
then the bss will start in the middle of the last page mmapped from the
executable. Since the remainder of the page will not necessarily
contain zeros as the bss requires, it needs to be manually zeroed. The
rest of the bss will be already zeroed, since it has been mmaped
anonymously/from /dev/zero.
J
|