This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: L4Ka. Regression with 4.7 and 4.8 ?
- From: Oleg Endo <oleg dot endo at t-online dot de>
- To: BERTRAND Joël <joel dot bertrand at systella dot fr>
- Cc: gcc-help at gcc dot gnu dot org, freevms at systella dot fr, L4 Mailing list <l4ka at ira dot uni-karlsruhe dot de>
- Date: Sun, 23 Jun 2013 12:31:44 +0200
- Subject: Re: L4Ka. Regression with 4.7 and 4.8 ?
- References: <51C1AB3A dot 5080907 at systella dot fr> <2138987 dot 2tPF7NEjmS at localhost> <51C376A5 dot 4060107 at systella dot fr> <51C59940 dot 3020009 at systella dot fr> <1371906201 dot 3742 dot 53 dot camel at yam-132-YW-E178-FTW> <51C5E4CB dot 40205 at systella dot fr> <1371924700 dot 3742 dot 108 dot camel at yam-132-YW-E178-FTW> <51C5FD3C dot 3070609 at systella dot fr> <1371932623 dot 3742 dot 132 dot camel at yam-132-YW-E178-FTW> <51C6C65B dot 50403 at systella dot fr>
On Sun, 2013-06-23 at 11:56 +0200, BERTRAND JoÃl wrote:
> Oleg Endo a Ãcrit :
> > On Sat, 2013-06-22 at 21:38 +0200, BERTRAND JoÃl wrote:
> >> Oleg Endo a Ãcrit :
> >>> The code in idt.c compiled with 4.6 puts static initialization functions
> >>> into the .ctors section, while 4.7 puts them into the .init_array
> >>> section. Probably this happens only for this single file in the whole
> >>> kernel. My guess is that the .init_array section is not handled
> >>> properly by the startup code of the kernel. Or maybe it's even stripped
> >>> out completely (missing in the linker script). Either way, it seems
> >>> that static initialization for idt.c is not being done properly and thus
> >>> the code crashes.
> >>
> >> I don't think that ctors are stripped by linker script. This script is
> >> built by makefile. Here is my script :
> >>
> >>
> >> OUTPUT_FORMAT("elf64-x86-64")
> >> OUTPUT_ARCH("i386:x86-64")
> >> BOOTMEM_SIZE = 1024K;
> >> ...
> >
> > As I initially assumed, the .init_array section seems to be missing in
> > the linker script, so it gets stripped. The .init_array section has to
> > be handled for code generated by GCC 4.7. I would say this is an issue
> > of the L4 software, not GCC.
>
> OK. I have done some test since yesterday. I have tried to include
> .init_array in kernel.
>
> If I modify my linker script like this :
>
> SECTIONS
> {
> . = ALIGN(4k);
> .text _start_text : AT (ADDR(.text) - KERNEL_OFFSET)
> {
> *(.text);
> *(.gnu.linkonce.*);
> *(.spinlock);
> }
>
> . = ALIGN(4k);
> .init_array . : AT (ADDR(.init_array) - KERNEL_OFFSET)
> {
> PROVIDE_HIDDEN (__init_array_start = .);
> KEEP (*(SORT(.init_array.*)))
> KEEP (*(.init_array))
> PROVIDE_HIDDEN (__init_array_end = .);
> }
>
> . = ALIGN(4k);
> .rodata . : AT (ADDR(.rodata) - KERNEL_OFFSET)
> ...
>
> I obtain a kernel with an .init_array section. But result is the same as
> I suppose that kickstart does not load this new section in memory.
>
> I have tried to write .init_array in .text section with :
>
> .text _start_text : AT (ADDR(.text) - KERNEL_OFFSET)
> {
> *(.text);
> *(.gnu.linkonce.*);
> *(.spinlock);
> PROVIDE_HIDDEN (__init_array_start = .);
> KEEP (*(SORT(.init_array.*)))
> KEEP (*(.init_array))
> PROVIDE_HIDDEN (__init_array_end = .);
> }
>
> I believe that .init_array is included in text section and loaded by
> kickstart into memory, but kernel only reboots too.
Simply merging .init_array into .text is not going to produce anything
but some unused data in .text.
.init_array is a vector of function pointers. These functions are
supposed to be invoked by the startup code before invoking 'main'.
You could try merging .init_array into the existing .ctors and see where
it goes.
BTW, searching the web for ".init_array" gives quite some useful
information.
Cheers,
Oleg