[klibc] klibc loader crash...
Paweł Sikora
pluto at agmk.net
Wed Oct 12 12:27:54 PDT 2005
Dnia środa, 12 października 2005 21:07, H. Peter Anvin napisał:
> 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
>
> Section to Segment mapping:
> Segment Sections...
> 00 .text
> 01 .data .bss
> 02
This is true only for statically linked klibc.
With shared version we get:
Sections:
Idx Name Size VMA LMA File off Algn
0 .interp 0000000e 080480f4 080480f4 000000f4 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .text 00000003 08048110 08048110 00000110 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x08048034 0x08048034 0x0000a0 0x0000a0 R E 0x4
INTERP 0x0000f4 0x080480f4 0x080480f4 0x00000e 0x00000e R 0x1
[Requesting program interpreter: /lib/klibc.so]
LOAD 0x000000 0x08048000 0x08048000 0x000113 0x000113 R E 0x1000
GNU_STACK 0x000000 0x00000000 0x00000000 0x000000 0x000000 RWE 0x4
LOOS+84153728 0x000000 0x00000000 0x00000000 0x000000 0x000000 0x4
Section to Segment mapping:
Segment Sections...
00
01 [RO: .interp]
02 [RO: .interp .text]
03
04
$ ld --version
GNU ld version 2.16.91.0.3 20050821
--
The only thing necessary for the triumph of evil
is for good men to do nothing.
- Edmund Burke
More information about the klibc
mailing list