I understand that the .exit.text section will be filled by the linker with functions defined with __exit macro. I can see the section on dissassembly of the vmlinux file. But I did not understand at what point are the contents discarded once the file is loaded in memory? Does it happen in the kernel code? Can anyone explain this more?
Thanks in advance!
1 回答
The files vmlinux.lds.S and module.c handle this. The handling depends on your kernel version and configuration; neither have been given. My assumption is you mean the .exit.text
section in the kernel and not some user space task. Generally, the kernel doesn't exit, so they are discarded by the linker script unless you have some debugging configurations.
Edit: The android kernel was made with a .config
file which enables Linux kernel features at compile time. The .config
for CONFIG_HOTPLUG_CPU is a CPU; some big servers can keep running even when the CPU is exchanged. It is hard to answer your question. I don't know where your Android kernel source is or what .config
options it was built with.
The sections are kept with GENERIC_BUG
; so it is possible your kernel was built with this. From the stock vmlinux.lds.S, the .exit.data
section is put before __init_end
, so it is freed and returned to memory after the init
portion runs. Ie, present only during boot. Under these circumstances, you will see it in the vmlinux ELF, but not in the runtime kcore or however you are dumping it.
Specifically, main.c's start_kernel()
, rest_init()
, kernel_init()
, and free_initmem()
are the place where this stuff is discarded.