Where does the linux kernel put local variables

Dave Hylands dhylands at gmail.com
Tue Aug 4 02:20:14 EDT 2015


Hi Rock,

On Mon, Aug 3, 2015 at 7:28 PM, Rock Lee <rocklee_104 at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150803/cef4f8c3/attachment.html 


More information about the Kernelnewbies mailing list