[klibc] klibc loader crash...
H. Peter Anvin
hpa at zytor.com
Wed Oct 12 12:07:59 PDT 2005
Paweł Sikora wrote:
> Hi,
>
> This is not a klibc bug. It is a kernel issue.
>
> Fixed in 2.6.14rc4-git1: [PATCH] binfmt_elf bss padding fix
>
> Nir Tzachar <tzachar at cs.bgu.ac.il> points out that if an ELF file specifies a
> zero-length bss at a whacky address, we cannot load that binary because
> padzero() tries to zero out the end of the page at the whacky address, and
> that may not be writeable.
>
> See also http://bugzilla.kernel.org/show_bug.cgi?id=5411
>
> So teach load_elf_binary() to skip the bss settng altogether if the elf file
> has a zero-length bss segment.
>
Hm. This still confuses me.
__libc_init() should always allocate three pointer values, so .bss
should never be empty with klibc-generated code.c. utils/true.c looks
like the following:
int main(void)
{
return 0;
}
... and it generates the following headers when compiled for i386:
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000070 08048094 08048094 00000094 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000004 08049104 08049104 00000104 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .bss 0000000c 08049108 08049108 00000108 2**2
ALLOC
... hmmm ...
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x08048000 0x08048000 0x00104 0x00104 R E 0x1000
LOAD 0x000104 0x08049104 0x08049104 0x00004 0x00010 RW 0x1000
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
Section to Segment mapping:
Segment Sections...
00 .text
01 .data .bss
02
... looks like the linker packs the .bss into the data segment if it's
small enough. Thus, the kernel doesn't see it.
This is a very good reason to fix the kernel.
-hpa
More information about the klibc
mailing list