Where does the linux kernel put local variables
Hi, all: I print a local variable address in start_kernel(), and I realize this address is between __data_start and _edata. In my opinion, local variables should be located in stack, why is this local variable located in data section? BTW, I use a arm11 board with linux-2.6.28. Thanks -- Rock Lee
Hi Rock, On Mon, Aug 3, 2015 at 7:28 PM, Rock Lee <rocklee_104@outlook.com> wrote:
Hi, all: I print a local variable address in start_kernel(), and I realize
this
address is between __data_start and _edata. In my opinion, local variables should be located in stack, why is this local variable located in data section? BTW, I use a arm11 board with linux-2.6.28.
If you look at the linker script file for the kernel http://lxr.free-electrons.com/source/arch/arm/kernel/vmlinux.lds.S#L244 , you'll see that INIT_TASK_DATA (which includes the kernel stack) is between _data and _edata. This is the stack used for kernel booting and then taken over by the init task. -- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com
Hi, Dave
If you look at the linker script file for the kernel http://lxr.free-electrons.com/source/arch/arm/kernel/vmlinux.lds.S#L244 , you'll see that INIT_TASK_DATA (which includes the kernel stack) is between _data and _edata. This is the stack used for kernel booting and then taken over by the init task.
Thanks for your advice ,after read http://lxr.free-electrons.com/source/arch/arm/kernel/head-common.S#L122, I'v got my answer. -- Rock Lee
participants (2)
-
Dave Hylands -
Rock Lee