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; _start_text_phys = 0x600000; _start_text = _start_text_phys + 0xFFFFFFFFC0000000; SECTIONS { . = ALIGN(4k); .text _start_text : AT (ADDR(.text) - 0xFFFFFFFFC0000000) { *(.text); *(.gnu.linkonce.*); *(.spinlock); } . = ALIGN(4k); .rodata . : AT (ADDR(.rodata) - 0xFFFFFFFFC0000000) { *(.rodata); *(.rodata.*); } . = ALIGN(4K); .kip . : AT (ADDR(.kip) - 0xFFFFFFFFC0000000) { *(.data.kip) *(.data.kip.pdesc) *(.data.kip.kdesc) *(.data.kip.versionparts) *(.data.kip.features) *(.data.kip.features.end) . = ALIGN(16); *(.data.kip.mdesc) _memory_descriptors_raw = ABSOLUTE((_memory_descriptors_offset << 32) + _memory_descriptors_size); } _memory_descriptors_offset = memory_descriptors - kip; _memory_descriptors_size = (4K - ((memory_descriptors - kip) & (4K-1))) / 16; . = ALIGN(((1 << 21))); _start_syscalls = .; .syscalls . : AT (ADDR(.syscalls) - 0xFFFFFFFFC0000000) { *(.user.syscall.ipc); . = ALIGN((0x100)); *(.user.syscall.lipc); . = ALIGN((0x100)); *(.user.syscall.exregs); . = ALIGN((0x100)); *(.user.syscall.threadctrl); . = ALIGN((0x100)); *(.user.syscall.sysclock); . = ALIGN((0x100)); *(.user.syscall.threadswtch); . = ALIGN((0x100)); *(.user.syscall.schedule); . = ALIGN((0x100)); *(.user.syscall.unmap); . = ALIGN((0x100)); *(.user.syscall.spacectrl); . = ALIGN((0x100)); *(.user.syscall.procctrl); . = ALIGN((0x100)); *(.user.syscall.memctrl); } . = ALIGN(((1 << 21))); _end_syscalls = .; . = ALIGN(((1 << 21))); _start_cpu_local = .; .cpulocal . : AT (ADDR(.cpulocal) - 0xFFFFFFFFC0000000) { *(.data.cpulocal) *(.data.x86.cpulocal) } . = ALIGN(((1 << 21))); _end_cpu_local = .; .data . : AT (ADDR(.data) - 0xFFFFFFFFC0000000) { *(.sdata); *(.data); *(.data.x86.idt); *(.data.x86.exc_all); *(.data.x86.exc_common); *(.data.*); _start_bss = .; *(.bss); _end_bss = .; } . = ALIGN(4K); .kdebug . : AT(ADDR(.kdebug) - 0xFFFFFFFFC0000000) { *(.kdebug); *(.kdebug-bss); *(.comment); } . = ALIGN(4K); .sets . : AT(ADDR(.sets) - 0xFFFFFFFFC0000000) { . = ALIGN(16); _start_setlist = .; *(.setlist) _end_setlist = .; . = ALIGN(16); _start_sets = .; *(SORT(set_*)) _end_sets = .; } . = ALIGN(4K); _end_text = .; . = ALIGN(4K); _start_bootmem = .; . = . + BOOTMEM_SIZE; _end_bootmem = .; . = ALIGN(4K); _start_init = . - 0xFFFFFFFFC0000000; .init (. - 0xFFFFFFFFC0000000) : AT(ADDR(.init)) { *(.init.startup32); . = ALIGN(1K); *(.init.init32) FILL(0x90909090); . = . + 1K; . = ALIGN(1K); *(.init.init64); *(.init); *(.roinit); *(.init.data); *(.init.memory); *(.init.cpulocal); *(.init.*); . = ALIGN(16); _start_mdb_funcs = .; *(SORT(.mdb_funcs*)) _end_mdb_funcs = .; . = ALIGN(16); /* cpu-local static initializers */ __ctors_CPU__ = .; *(SORT(.ctors.3*)) QUAD(0) /* node-local static initializers */ __ctors_NODE__ = .; *(SORT(.ctors.2*)) QUAD(0) /* global static initializers */ __ctors_GLOBAL__ = .; *(SORT(.ctors.1*)) *(SORT(.ctors.*)) *(.ctors) QUAD(0) } _end_init = .; /* special section that is discarded during linking all unwanted sections should go here */ . = ALIGN(4K); /DISCARD/ : { *(.eh_frame); *(.note); *(.comment); } } /* physical addresses */ _end_text_phys = _end_text - 0xFFFFFFFFC0000000; _start_syscalls_phys = _start_syscalls - 0xFFFFFFFFC0000000; _end_syscalls_phys = _end_syscalls - 0xFFFFFFFFC0000000; _start_bootmem_phys = _start_bootmem - 0xFFFFFFFFC0000000; _end_bootmem_phys = _end_bootmem - 0xFFFFFFFFC0000000; Regards, JKB