Date: Mon, 08 Oct 2001 09:24:44 -0700 From: Peter Wemm <peter@wemm.org> To: Mark Peek <mark@whistle.com> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Change to ldscript.i386 Message-ID: <20011008162444.BAD02380F@overcee.netplex.com.au> In-Reply-To: <p05101000b7e77470ca47@[207.76.207.129]>
next in thread | previous in thread | raw e-mail | index | archive | help
Mark Peek wrote: > I made a change to page align the data segment on the powerpc port and I > noticed something strange with the i386 alignment. The data section appears > to be wasting space by aligning to the same address (offset) in the next > page rather than to the next page boundary. Below is the patch and a > before/after objdump of the kernel headers. The difference isn't that big > (no more than 4K) but my patch seems more correct. > > Am I missing any reason why it was done this way? If not, I'll apply the > patch to -current. It is sone this way because that's the way standard ELF files are laid out. Using the same next address means that you dont have to put padding in the file itself, and can simply double map the same page when loading executables. Before: Idx Name Size VMA LMA File off Algn 17 set_vga_set 0000001c c0398248 c0398248 00298248 2**2 18 .data 00049d20 c0399280 c0399280 00298280 2**5 Note the file offset from section 17 -> 18 is increased by 28 bytes. After: Idx Name Size VMA LMA File off Algn 17 set_vga_set 0000001c c0398248 c0398248 00298248 2**2 18 .data 00049d20 c0399000 c0399000 00299000 2**5 Now the file offset is increased by 3512 bytes instead of 28 bytes. But note that also the virtual address of .data is lower. Anyway, that is why it was done that way. What is or isn't good for application executables doesn't necessarily apply to the kernel since it isn't demand paged. In the kernel case the larger file size may actually end up using one less page of actual memory for the kernel data segment. However, I seem to recall Bruce telling me once that the 4MB page implementation breaks something with the text read-only protection, so doing any roundup at all is probably futile. Incidently, I have long been tempted to make a similar change to the *userland* elf executable layout. I think this will significantly speed up executable exec() times since we wont have to do the silly BSS pre-zero on the bounary page, which will case an out-of-order page read. If the VM system supported a "post faultin" callback hook we could avoid that. Cheers, -Peter -- Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011008162444.BAD02380F>