vmlinux.lds.S linker script
I'll provide concrete examples to explain the key aspects of the vmlinux.lds.S linker script:
#ifdef CONFIG_XIP_KERNEL
#include "vmlinux-xip.lds.S"
#else // Rest of the linker script #endif
Example scenario:
/DISCARD/ : { ARM_DISCARD
#ifndef CONFIG_SMP_ON_UP
*(.alt.smp.init)
#endif
#ifndef CONFIG_ARM_UNWIND
*(.ARM.exidx) *(.ARM.exidx.*) *(.ARM.extab) *(.ARM.extab.*)
#endif }
Concrete examples:
. = KERNEL_OFFSET + TEXT_OFFSET; ENTRY(stext)
Real-world example:
#ifndef __ARMEB__
jiffies = jiffies_64;
#else jiffies = jiffies_64 + 4;
#endif
Explanation:
.head.text : {
_text = .;
HEAD_TEXT . = ALIGN(8);
}
Practical meaning:
Let me view more of the file to provide additional context:
领英推荐
Analyzed
vmlinux.lds.S:(100-200)
.init.tagtable : {
__tagtable_begin = .;
*(.taglist.init)
__tagtable_end = .;
}
Example use:
#ifdef CONFIG_SMP_ON_UP
.init.smpalt : {
__smpalt_begin = .;
*(.alt.smp.init)
__smpalt_end = .; }
#endif
Practical scenario:
#ifdef CONFIG_STRICT_KERNEL_RWX
. = ALIGN(1<<SECTION_SHIFT);
#else
. = ALIGN(THREAD_ALIGN);
#endif
Real-world implications:
ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
#ifndef CONFIG_COMPILE_TEST ASSERT
((__arch_info_end - __arch_info_begin), "no machine record defined")
#endif
Purpose:
The linker script is essentially a blueprint that tells the linker how to construct the final kernel binary, taking into account: