跟我学系列-移植内核必备知识-对linux的early printk的探讨
嵌入式开发联盟
www.mcuos.com
Osboy 站长原创
QQ:82475491
vmlinux.lds.S是如何组织内核的每个函数存放在内核镜像文件的位置,我们知道你在编译内核生成内核文件的时候,其实这个过程分两步,一个是“编译”,另一个是“链接”的过程,vmlinux.lds.S要做的就是告诉编译器如何链接编译好的各个内核.o文件。
- 小知识:链接器中的entry
- 链接器 按以下优先顺序设入口点,找到即停止
- 1 -e 命令行选项
- 2 脚本中的entry(symbol)命令
- 3如定义了start的值,取其值为入口点
- 4.text的第一个字节的地址
- 5地址0
所以你可以从vmlinux.lds.S下面的代码中看到:
- OUTPUT_ARCH(arm)
- ENTRY(stext)
表明我们指定stext作为, 程序 的入口点。
上代码:
- SECTIONS
- {
- #ifdef CONFIG_XIP_KERNEL
- . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
- #else
- . = PAGE_OFFSET + TEXT_OFFSET;
- #endif
-
- .init : { /* Init code and data */
- _stext = .;
- _sinittext = .;
- HEAD_TEXT
- INIT_TEXT
- ARM_EXIT_KEEP(EXIT_TEXT)
- _einittext = .;
- ARM_CPU_DISCARD(PROC_INFO)
- __arch_info_begin = .;
- *(.arch.info.init)
- __arch_info_end = .;
- __tagtable_begin = .;
- *(.taglist.init)
- __tagtable_end = .;
- #ifdef CONFIG_SMP_ON_UP
- __smpalt_begin = .;
- *(.alt.smp.init)
- __smpalt_end = .;
- #endif
-
- __pv_table_begin = .;
- *(.pv_table)
- __pv_table_end = .;
-
- INIT_SETUP(16)
-
- INIT_CALLS
- CON_INITCALL
- SECURITY_INITCALL
- INIT_RAM_FS
-
- #ifndef CONFIG_XIP_KERNEL
- __init_begin = _stext;
- INIT_DATA
- ARM_EXIT_KEEP(EXIT_DATA)
- #endif
- }
-
- PERCPU_SECTION(32)
-
- #ifndef CONFIG_XIP_KERNEL
- . = ALIGN(PAGE_SIZE);
- __init_end = .;
- #endif
-
- /*
- * unwind exit sections must be discarded before the rest of the
- * unwind sections get included.
- */
- /DISCARD/ : {
- *(.ARM.exidx.exit.text)
- *(.ARM.extab.exit.text)
- ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
- ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
- #ifndef CONFIG_HOTPLUG
- *(.ARM.exidx.devexit.text)
- *(.ARM.extab.devexit.text)
- #endif
- #ifndef CONFIG_MMU
- *(.fixup)
- *(__ex_table)
- #endif
- }
-
- .text : { /* Real text segment */
- _text = .; /* Text and read-only data */
- __exception_text_start = .;
- *(.exception.text)
- __exception_text_end = .;
- IRQENTRY_TEXT
- TEXT_TEXT
- SCHED_TEXT
- LOCK_TEXT
- KPROBES_TEXT
- #ifdef CONFIG_MMU
- *(.fixup)
- #endif
- *(.gnu.warning)
- *(.rodata)
- *(.rodata.*)
- *(.glue_7)
- *(.glue_7t)
- . = ALIGN(4);
- *(.got) /* Global offset table */
- ARM_CPU_KEEP(PROC_INFO)
- }
-
- RO_DATA(PAGE_SIZE)
-
- #ifdef CONFIG_ARM_UNWIND
- /*
- * Stack unwinding tables
- */
- . = ALIGN(8);
- .ARM.unwind_idx : {
- __start_unwind_idx = .;
- *(.ARM.exidx*)
- __stop_unwind_idx = .;
- }
- .ARM.unwind_tab : {
- __start_unwind_tab = .;
- *(.ARM.extab*)
- __stop_unwind_tab = .;
- }
- #endif
-
- _etext = .; /* End of text and rodata section */
-
- #ifdef CONFIG_XIP_KERNEL
- __data_loc = ALIGN(4); /* location in binary */
- . = PAGE_OFFSET + TEXT_OFFSET;
- #else
- . = ALIGN(THREAD_SIZE);
- __data_loc = .;
- #endif
-
- .data : AT(__data_loc) {
- _data = .; /* address in memory */
- _sdata = .;
-
- /*
- * first, the init task union, aligned
- * to an 8192 byte boundary.
- */
- INIT_TASK_DATA(THREAD_SIZE)
-
- #ifdef CONFIG_XIP_KERNEL
- . = ALIGN(PAGE_SIZE);
- __init_begin = .;
- INIT_DATA
- ARM_EXIT_KEEP(EXIT_DATA)
- . = ALIGN(PAGE_SIZE);
- __init_end = .;
- #endif
-
- NOSAVE_DATA
- CACHELINE_ALIGNED_DATA(32)
- READ_MOSTLY_DATA(32)
-
- /*
- * The exception fixup table (might need resorting at runtime)
- */
- . = ALIGN(32);
- __start___ex_table = .;
- #ifdef CONFIG_MMU
- *(__ex_table)
- #endif
- __stop___ex_table = .;
-
- /*
- * and the usual data section
- */
- DATA_DATA
- CONSTRUCTORS
-
- _edata = .;
- }
- _edata_loc = __data_loc + SIZEOF(.data);
-
- #ifdef CONFIG_HAVE_TCM
- /*
- * We align everything to a page boundary so we can
- * free it after init has commenced and TCM contents have
- * been copied to its destination.
- */
- .tcm_start : {
- . = ALIGN(PAGE_SIZE);
- __tcm_start = .;
- __itcm_start = .;
- }
-
- /*
- * Link these to the ITCM RAM
- * Put VMA to the TCM address and LMA to the common RAM
- * and we'll upload the contents from RAM to TCM and free
- * the used RAM after that.
- */
- .text_itcm ITCM_OFFSET : AT(__itcm_start)
- {
- __sitcm_text = .;
- *(.tcm.text)
- *(.tcm.rodata)
- . = ALIGN(4);
- __eitcm_text = .;
- }
-
- /*
- * Reset the dot pointer, this is needed to create the
- * relative __dtcm_start below (to be used as extern in code).
- */
- . = ADDR(.tcm_start) + SIZEOF(.tcm_start) + SIZEOF(.text_itcm);
-
- .dtcm_start : {
- __dtcm_start = .;
- }
-
- /* TODO: add remainder of ITCM as well, that can be used for data! */
- .data_dtcm DTCM_OFFSET : AT(__dtcm_start)
- {
- . = ALIGN(4);
- __sdtcm_data = .;
- *(.tcm.data)
- . = ALIGN(4);
- __edtcm_data = .;
- }
-
- /* Reset the dot pointer or the linker gets confused */
- . = ADDR(.dtcm_start) + SIZEOF(.data_dtcm);
-
- /* End marker for freeing TCM copy in linked object */
- .tcm_end : AT(ADDR(.dtcm_start) + SIZEOF(.data_dtcm)){
- . = ALIGN(PAGE_SIZE);
- __tcm_end = .;
- }
- #endif
-
- NOTES
-
- BSS_SECTION(0, 0, 0)
- _end = .;
-
- STABS_DEBUG
- .comment 0 : { *(.comment) }
-
- /* Default discards */
- DISCARDS
-
- #ifndef CONFIG_SMP_ON_UP
- /DISCARD/ : {
- *(.alt.smp.init)
- }
- #endif
- }
先看第一个知识点:
(1). = PAGE_OFFSET + TEXT_OFFSET;
arch/arm/include/asm中的memory.h文件定义了:
- #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
CONFIG_PAGE_OFFSET是在内核配置里面配置的,比如拿ok6410来说,我的配置:
- #define CONFIG_PAGE_OFFSET 0xC0000000
PAGE_OFFSET代表是的内核image的的起始虚拟地址。
在arch/arm/Makefile中有定义:
- textofs-y := 0x00008000
- TEXT_OFFSET := $(textofs-y)
TEXT_OFFSET代表的是内核的image存放在内存中地址,注意这个地址为相对于内存的起始地址的偏移量,是个相对的偏移量不是实际的存放内存物理地址。而且这个偏移量取得有讲究,必须为:0xXXXX8000,xxx为任意值。
所以:. = PAGE_OFFSET + TEXT_OFFSET就变成为:.=c0008000,这个地址就是内核存放在内存的虚拟的起始地址。从脚本来看,也就是.stext的地址就是:c0008000,那么我们如何验证我们的这个说法呢,你可以打开linux目录下的System.map文件查看:
- 00000020 A cpu_v6_suspend_size
- c0004000 A swapper_pg_dir
- c0008000 T __init_begin
- c0008000 T _stext T _sinittext
- c0008000 T _stext
- c0008000 T stext
- c000804c t __create_page_tables
- c0008148 t __enable_mmu_loc
- c0008154 t __enable_mmu
- c0008180 t __turn_mmu_on
- c0008198 t __enable_mmu_end
- c0008198 t __vet_atags
- c00081e0 t __mmap_switched
- c0008228 t __mmap_switched_data
- c000824c T lookup_processor_type
- c0008260 t set_reset_devices
- c0008284 t debug_kernel
从map文件可以知道_stext是内核的入口地址,这个地址就是c0008000,这也验证了我们在第一章讲搭建环境的时候,我为什么要用dnw c0008000,就是因为我们已经指定好了,内核的存放地址必须为c0008000,针对ok6410来说。
(二).init内核的初始化代码和数据段
- _sinittext = .;
- HEAD_TEXT
- INIT_TEXT
- ARM_EXIT_KEEP(EXIT_TEXT)
- _einittext = .;
从上面的链接脚本可以知道所有:_sinittext开头的,_einittext结尾的HEAD_TEXT, INIT_TEXT,ARM_EXIT_KEEP(EXIT_TEXT)段都是从起始地址c0008000开始存放的。这些宏定义在:include/asm-generic/vmlinux.lds.h中。
- __arch_info_begin = .;
- *(.arch.info.init)
- __arch_info_end = .;
- __tagtable_begin = .;
- *(.taglist.init)
- __tagtable_end = .;
- #ifdef CONFIG_SMP_ON_UP
- __smpalt_begin = .;
- *(.alt.smp.init)
- __smpalt_end = .;
- #endif
-
- __pv_table_begin = .;
- *(.pv_table)
- __pv_table_end = .;
紧接着以此存放的是:*(.arch.info.init), *(.taglist.init),*(.alt.smp.init),*(.pv_table)段的代码,其中我们最熟悉的*(.arch.info.init)段的代码就是:
- #define MACHINE_START(_type,_name) \
- static const struct machine_desc __mach_desc_##_type \
- __used \
- __attribute__((__section__(".arch.info.init"))) = { \
- .nr = MACH_TYPE_##_type, \
- .name = _name,
-
- #define MACHINE_END \
- };
也就是说所有平台的下面这段代码都放到了*(.arch.info.init)段中:
- MACHINE_START(MCUOS6410, "MCUOS6410")
- /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
- .boot_params = S3C64XX_PA_SDRAM + 0x100,
-
- .init_irq = s3c6410_init_irq,
- .map_io = mcuos6410_map_io,
- .init_machine = mcuos6410_machine_init,
- .timer = &s3c24xx_timer,
- MACHINE_END
紧接着存放的是初始化数据段:
- #ifndef CONFIG_XIP_KERNEL
- __init_begin = _stext;
- INIT_DATA
- ARM_EXIT_KEEP(EXIT_DATA)
- #endif
- }
-
- PERCPU_SECTION(32)
-
- #ifndef CONFIG_XIP_KERNEL
- . = ALIGN(PAGE_SIZE);
- __init_end = .;
- #endif
这个段存放的是所有*(.init.data),*(.init.rodata)段中的代码。
.init段中的代码段和数据段,在Linux初始化完成之后,这个段的内存都会被请空,被释放。因为他们只需要在初始化的时候使用一次,没有必要再驻留在内存中,浪费空间。为了验证我们以上的分析,我们可以查看system.map这个文件,下面我们看到的从_sinittext开头的,_einittext结尾的所有函数,都会在初始化完成之后被释放:
- c0008000 T _sinittext
- c0008000 T _stext
- c0008000 T stext
- c000804c t __create_page_tables
- c0008148 t __enable_mmu_loc
- c0008154 t __enable_mmu
- c0008180 t __turn_mmu_on
- c0008198 t __enable_mmu_end
- c0008198 t __vet_atags
- c00081e0 t __mmap_switched
- c0008228 t __mmap_switched_data
- c000824c T lookup_processor_type
- c0008260 t set_reset_devices
- c0008284 t debug_kernel
- c00082a8 t quiet_kernel
- c00082cc t init_setup
- c0008308 t rdinit_setup
- c0008344 W smp_setup_processor_id
- c0008354 W thread_info_cache_init
- c0008364 t loglevel
- c0008398 T parse_early_options
- c00083d4 t unknown_bootoption
- c00085f8 T parse_early_param
- c0008648 t do_early_param
- c0008724 t kernel_init
- c0008850 T start_kernel
- c0008b9c t readonly
- c0008bd0 t readwrite
- c0008c04 t rootwait_setup
- c0008c34 t root_data_setup
- c0008c54 t fs_names_setup
- c0008c74 t load_ramdisk
- c0008ca4 t root_dev_setup
- c0008ccc t root_delay_setup
- c0008cf8 T change_floppy
- c0008e20 T mount_block_root
- c0009108 T mount_root
- c0009174 T prepare_namespace
- c0009364 t ramdisk_start_setup
- c0009390 t prompt_ramdisk
- c00093c0 t error
- c00093fc t compr_fill
- c0009464 t compr_flush
- c00094d4 T rd_load_image
- c0009b5c T rd_load_disk
- c0009c10 t no_initrd
- c0009c34 T initrd_load
- c0009f74 t do_linuxrc
- c0009fc8 t error
- c0009fec t read_into
- c000a0a8 t do_start
- c000a0d4 t write_buffer
- c000a12c t flush_buffer
- c000a1d8 t retain_initrd_param
- c000a208 t clean_path
- c000a268 t do_utime
- c000a2ac t do_symlink
- c000a378 t unpack_to_rootfs
- c000a6d4 t maybe_link
- c000a840 t do_name
- c000aad8 t do_header
- c000adf0 t free_initrd
- c000aed0 t populate_rootfs
- c000b124 t do_collect
- c000b1ec t do_skip
- c000b2c0 t do_reset
- c000b38c t do_copy
- c000b4b8 t lpj_setup
- c000b500 T __kuser_helper_start
- c000b500 t __kuser_memory_barrier
- c000b520 t __kuser_cmpxchg
- c000b540 t __kuser_get_tls
- c000b55c t __kuser_helper_version
- c000b560 T __kuser_helper_end
- c000b560 T __stubs_start
- c000b560 t vector_irq
- c000b5e0 t vector_dabt
- c000b660 t vector_pabt
- c000b6e0 t vector_und
- c000b760 t vector_fiq
- c000b764 t vector_addrexcptn
- c000b784 T __stubs_end
- c000b784 T __vectors_start
- c000b7a4 T __vectors_end
- c000b7c0 T init_IRQ
- c000b7e4 T arch_probe_nr_irqs
- c000b818 t nohlt_setup
- c000b83c t hlt_setup
- c000b860 T reboot_setup
- c000b884 t ptrace_break_init
- c000b8bc t parse_tag_core
- c000b914 t parse_tag_videotext
- c000b994 t parse_tag_ramdisk
- c000b9fc t parse_tag_serialnr
- c000ba30 t parse_tag_revision
- c000ba54 t customize_machine
- c000ba84 t parse_tag_cmdline
- c000baac t topology_init
- c000badc t proc_cpu_init
- c000bb08 T arm_add_memory
- c000bba0 t parse_tag_mem32
- c000bbbc t early_mem
- c000bc38 T early_print
- c000bcb0 T dump_machine_table
- c000bd10 T setup_arch
- c000c5fc T time_init
- c000c630 t timer_init_syscore_ops
- c000c650 T trap_init
- c000c660 t user_debug_setup
- c000c694 T early_trap_init
- c000c7a8 T arch_init_kprobes
- c000c7cc T arm_kprobe_decode_init
- c000c800 T save_atags
- c000c824 t init_atags_procfs
- c000c934 T unwind_init
- c000c97c t arch_hw_breakpoint_init
- c000cb8c t register_pmu_driver
- c000cba8 t armpmu_reset
- c000cbf4 t init_hw_perf_events
- c000cd3c t setup_early_printk
- c000cd5c t dma_debug_do_init
- c000cd70 t consistent_init
- c000ce64 T hook_ifault_code
- c000ceb8 T hook_fault_code
- c000cf10 t exceptions_init
- c000cfac t parse_tag_initrd2
- c000cfe0 t meminfo_cmp
- c000d014 t keepinitrd_setup
- c000d038 t early_initrd
- c000d09c t parse_tag_initrd
- c000d0e8 T mem_init
- c000d7cc T bootmem_init
- c000da94 T arm_memblock_init
- c000dc1c T check_writebuffer_bugs
- c000dd64 t early_ecc
- c000ddd0 t early_cachepolicy
- c000ded0 t early_nowrite
- c000df08 t early_nocache
- c000df40 t early_vmalloc
- c000dfc4 t early_alloc
- c000dffc t early_pte_alloc
- c000e08c t create_mapping
- c000e3e8 T paging_init
- c000eabc T iotable_init
- c000eaf8 T arm_mm_memblock_reserve
- c000eb18 T sanity_check_meminfo
- c000ed58 t noalign_setup
- c000eda0 t alignment_init
- c000ee90 t v6_userpage_init
- c000eed4 T v6wbi_tlb_fns
- c000eee0 t vic_disable
- c000ef28 t vic_clear_interrupts
- c000ef6c t vic_set_irq_sources
- c000eff0 T vic_init
- c000f12c t s3c64xx_sysdev_init
- c000f154 T s3c64xx_init_io
- c000f1b0 T s3c6400_common_init_uarts
- c000f1dc T s3c64xx_register_clocks
- c000f264 T s3c6400_setup_clocks
- c000f4ec t s3c64xx_gpiolib_add_2bit
- c000f504 t s3c64xx_gpiolib_add
- c000f54c t s3c64xx_gpiolib_init
- c000f5a8 T s3c6410_map_io
- c000f5e0 t s3c6410_core_init
- c000f5fc T s3c6410_init
- c000f624 T s3c6410_init_irq
- c000f640 T s3c6410_init_clocks
- c000f67c T s3c64xx_init_irq
- c000f6f0 t s3c64xx_init_irq_eint
- c000f7dc t s3c64xx_dma_init
- c000f8c0 t mcuos6410_machine_init
- c000f8e0 t mcuos6410_map_io
- c000f91c T s3c64xx_ac97_setup_gpio
- c000f954 T s3c24xx_init_clocks
- c000f9b0 t s3c_arch_init
- c000fa08 T s3c24xx_init_uarts
- c000fa4c T s3c_init_cpu
- c000fb1c T s3c24xx_init_uartdevs
- c000fbb4 t s3c2410_timer_init
- c000fc94 T s3c_disable_clocks
- c000fccc T s3c24xx_register_baseclocks
- c000fe08 T s3c_register_clocks
- c000fe64 T s3c_pwmclk_init
- c000ffd4 T s3c_gpiolib_add
- c00100f4 T s3c_set_clksrc
- c00101cc T s3c_register_clksrc
- c00102d0 T s3c_init_uart_irqs
- c00103d4 T s3c_init_vic_timer_irq
- c001052c t adc_init
- c001056c T s3c_set_platdata
- c00105c8 T s3c_i2c0_set_platdata
- c0010638 T s3c_nand_set_platdata
- c0010784 t sched_init_debug
- c00107c4 t init_sched_debug_procfs
- c001080c T sched_init_smp
- c0010878 T sched_init
- c0010ab0 t proc_schedstat_init
- c0010af0 t coredump_filter_setup
- c0010b24 T fork_init
- c0010bc0 T proc_caches_init
- c0010cdc t proc_execdomains_init
- c0010d1c t oops_setup
- c0010d5c t console_suspend_disable
- c0010d80 t log_buf_len_setup
- c0010de0 t console_setup
- c0010f1c t printk_late_init
- c0010f9c t keep_bootcon_setup
- c0010fcc t ignore_loglevel_setup
- c0010ffc T setup_log_buf
- c0011184 T softirq_init
- c0011214 W arch_early_irq_init
- c0011228 t spawn_ksoftirqd
- c001127c t reserve_setup
- c0011370 t strict_iomem
- c00113cc t __reserve_region_with_split
- c00114ac T reserve_region_with_split
- c00114c0 t ioresources_init
- c0011520 t sysctl_init
- c0011564 t file_caps_disable
- c0011588 T init_timers
- c00115e4 t uid_cache_init
- c0011670 t setup_print_fatal_signals
- c00116a4 T signals_init
- c00116e8 T usermodehelper_init
- c0011748 t init_workqueues
- c00119d8 T pidmap_init
- c0011ad8 T pidhash_init
- c0011b5c T sort_main_extable
- c0011b80 t locate_module_kobject
- c0011c80 t param_sysfs_init
- c0011ea0 t init_posix_timers
- c0012098 t init_posix_cpu_timers
- c00121a0 T hrtimers_init
- c00121c4 t nsproxy_cache_init
- c001220c t ksysfs_init
- c00122ac t pm_qos_power_init
- c001233c T cred_init
- c0012380 t timekeeping_init_ops
- c00123a0 T timekeeping_init
- c00124b0 t ntp_tick_adj_setup
- c00124e4 T ntp_init
- c0012520 t init_clocksource_sysfs
- c0012580 t boot_override_clocksource
- c00125cc t boot_override_clock
- c0012628 t clocksource_done_booting
- c0012690 W clocksource_default_clock
- c00126a8 t init_jiffies_clocksource
- c00126c4 t init_timer_list_procfs
- c001270c t alarmtimer_init
- c0012850 T init_timer_stats
- c0012860 t init_tstats_procfs
- c00128a8 t futex_init
- c0012920 t proc_modules_init
- c0012960 t kallsyms_init
- c00129a0 t crash_notes_memory_init
- c00129e4 t crash_save_vmcoreinfo_init
- c0012dac T parse_crashkernel
- c0013114 t pid_namespaces_init
- c001315c t audit_enable
- c0013244 t audit_init
- c001338c T audit_register_class
- c001345c t init_kprobes
- c00135a0 t hung_task_panic_setup
- c00135cc t hung_task_init
- c0013630 T early_irq_init
- c0013708 t irqpoll_setup
- c0013744 t irqfixup_setup
- c0013784 t irq_gc_init_ops
- c00137a4 t rcu_spawn_kthreads
- c001380c t relay_init
- c0013820 t utsname_sysctl_init
- c0013840 t init_lstats_procfs
- c0013880 t rb_init_debugfs
- c00138c8 t set_cmdline_ftrace
- c0013910 t set_ftrace_dump_on_oops
- c0013978 t set_buf_size
- c00139c8 t clear_boot_tracer
- c0013a08 t tracer_init_debugfs
- c0013d48 t set_tracing_thresh
- c0013da8 t tracer_alloc_buffers
- c0013f1c t init_events
- c0013fb0 t init_trace_printk_function_export
- c0013ffc t init_trace_printk
- c0014018 t setup_trace_event
- c0014058 t event_trace_init
- c001435c t init_kprobe_trace
- c00143fc t perf_event_sysfs_init
- c00144c0 T perf_event_init
- c00145d8 T init_hw_breakpoint
- c0014680 T set_dma_reserve
- c001469c T page_alloc_init
- c00146ac T free_area_init_node
- c0014a38 T free_area_init
- c0014a5c T setup_per_cpu_pageset
- c0014af8 T alloc_large_system_hash
- c0014d6c T page_writeback_init
- c0014dac T swap_setup
- c0014e00 t kswapd_init
- c0014e20 T init_tmpfs
- c0014f0c t setup_vmstat
- c0014fac t bdi_class_init
- c0015018 t default_bdi_init
- c00150e0 t set_mminit_loglevel
- c0015114 t mm_sysfs_init
- c0015158 T mminit_verify_pageflags_layout
- c001526c T percpu_init_late
- c0015304 T pcpu_setup_first_chunk
- c0015b78 T pcpu_free_alloc_info
- c0015b98 T pcpu_alloc_alloc_info
- c0015c2c T setup_per_cpu_areas
- c0015cc4 T page_address_init
- c0015d68 t disable_randmaps
- c0015d8c t init_zero_pfn
- c0015dd0 T mmap_init
- c0015df4 T anon_vma_init
- c0015e68 T vm_area_register_early
- c0015ee8 t proc_vmalloc_init
- c0015f28 T vmalloc_init
- c0015fd8 t bootmem_debug_setup
- c0015ffc t bootmap_bytes
- c001601c T bootmem_bootmap_pages
- c001603c t align_idx
- c0016068 t alloc_arch_preferred_bootmem
- c00160c8 t __free
- c001618c t __reserve
- c0016288 t alloc_bootmem_core
- c0016618 t ___alloc_bootmem_nopanic
- c00166e4 T __alloc_bootmem_nopanic
- c00166fc t mark_bootmem_node
- c00167dc T reserve_bootmem_node
- c0016818 t mark_bootmem
- c0016934 T reserve_bootmem
- c0016964 W reserve_bootmem_generic
- c0016978 T free_bootmem
- c00169a8 t ___alloc_bootmem
- c00169e4 T __alloc_bootmem_low
- c00169fc t ___alloc_bootmem_node
- c0016a70 T __alloc_bootmem_low_node
- c0016b04 T __alloc_bootmem_node
- c0016b90 T __alloc_bootmem_node_high
- c0016ba4 T __alloc_bootmem
- c0016bbc t free_all_bootmem_core
- c0016e10 T free_all_bootmem
- c0016e64 T free_all_bootmem_node
- c0016e7c t init_bootmem_core
- c0016f8c T init_bootmem
- c0016fd8 T init_bootmem_node
- c0016ff0 T free_bootmem_late
- c0017064 T free_bootmem_node
- c00170a4 T __alloc_bootmem_node_nopanic
- c0017174 W memblock_nid_range
- c0017190 T memblock_phys_mem_size
- c00171ac T memblock_enforce_memory_limit
- c00172bc T memblock_is_reserved
- c00172e4 T memblock_init
- c001736c t early_memblock
- c00173a8 t memblock_init_debugfs
- c0017428 T memblock_analyze
- c00174f0 T memblock_alloc_nid
- c0017610 T __memblock_alloc_base
- c001766c T memblock_alloc_base
- c00176b4 T memblock_alloc_try_nid
- c00176e8 T memblock_alloc
- c0017700 t init_emergency_pool
- c00177b4 t max_swapfiles_check
- c00177c8 t procswaps_init
- c0017808 t setup_slub_nomerge
- c001782c t kmem_cache_bootstrap_fixup
- c00178c0 T kmem_cache_init_late
- c00178d0 t setup_slub_min_objects
- c0017904 t setup_slub_max_order
- c001794c t setup_slub_min_order
- c0017980 t slab_proc_init
- c00179c0 t setup_slub_debug
- c0017b80 t slab_sysfs_init
- c0017cd8 t create_kmalloc_cache
- c0017d6c T kmem_cache_init
- c001801c T files_init
- c00180a8 T chrdev_init
- c00180e4 t init_pipe_fs
- c0018140 t fcntl_init
- c0018188 t set_dhash_entries
- c00181d0 T vfs_caches_init
- c0018324 T vfs_caches_init_early
- c00183d0 t set_ihash_entries
- c0018418 T inode_init
- c0018508 T inode_init_early
- c00185b0 T files_defer_init
- c0018600 t proc_filesystems_init
- c0018640 T get_filesystem_list
- c00186bc T mnt_init
- c0018894 T buffer_init
- c0018908 t init_bio
- c0018a74 T bdev_cache_init
- c0018b10 T bio_integrity_init
- c0018bec t fsnotify_init
- c0018c18 T fsnotify_notification_init
- c0018ccc t fsnotify_mark_init
- c0018d14 t dnotify_init
- c0018db0 t inotify_user_setup
- c0018e50 t eventpoll_init
- c0018f50 t anon_inode_init
- c001908c t aio_setup
- c001913c t proc_locks_init
- c001917c t filelock_init
- c00191c8 t init_script_binfmt
- c00191e8 t init_elf_binfmt
- c0019208 t init_mbcache
- c0019228 T proc_init_inodecache
- c0019270 T proc_root_init
- c001933c T proc_tty_init
- c00193ec t proc_cmdline_init
- c001942c t proc_consoles_init
- c001946c t proc_cpuinfo_init
- c00194ac t proc_devices_init
- c00194ec t proc_interrupts_init
- c001952c t proc_loadavg_init
- c001956c t proc_meminfo_init
- c00195ac t proc_stat_init
- c00195ec t proc_uptime_init
- c001962c t proc_version_init
- c001966c t proc_softirqs_init
- c00196ac T proc_sys_init
- c00196f0 T proc_net_init
- c0019724 t proc_net_ns_init
- c00197d8 t proc_kmsg_init
- c0019818 t proc_page_init
- c0019878 T sysfs_inode_init
- c0019894 T sysfs_init
- c001995c t init_devpts_fs
- c00199b8 t init_ext3_fs
- c0019a3c T init_ext3_xattr
- c0019a78 T journal_init_revoke_caches
- c0019b38 t journal_init
- c0019c0c t init_cramfs_fs
- c0019c50 t init_ramfs_fs
- c0019c6c T init_rootfs
- c0019cbc T fat_cache_init
- c0019d14 t init_fat_fs
- c0019d80 t init_vfat_fs
- c0019d9c t init_msdos_fs
- c0019db8 t init_nls_cp437
- c0019dd4 t init_nls_cp936
- c0019df0 t init_nls_ascii
- c0019e0c t init_nls_iso8859_1
- c0019e28 t init_nls_utf8
- c0019e68 t debugfs_init
- c0019ee0 t ipc_init
- c0019f0c T ipc_init_proc_interface
- c0019fa4 T msg_init
- c0019ff8 T sem_init
- c001a034 T shm_init
- c001a070 t ipc_sysctl_init
- c001a090 T key_init
- c001a14c t key_proc_init
- c001a1a0 t init_mmap_min_addr
- c001a1b8 t crypto_wq_init
- c001a20c t crypto_algapi_init
- c001a224 T crypto_init_proc
- c001a260 t skcipher_module_init
- c001a288 t chainiv_module_init
- c001a2a4 t eseqiv_module_init
- c001a2c0 t cryptomgr_init
- c001a2dc t hmac_module_init
- c001a2f8 t md5_mod_init
- c001a314 t sha1_generic_mod_init
- c001a330 t crypto_ecb_module_init
- c001a34c t crypto_cbc_module_init
- c001a368 t des_generic_mod_init
- c001a3b8 t aes_init
- c001a3d4 t arc4_init
- c001a3f0 t michael_mic_init
- c001a40c t crc32c_mod_init
- c001a428 t crypto_authenc_module_init
- c001a444 t crypto_authenc_esn_module_init
- c001a460 t krng_mod_init
- c001a47c t elevator_setup
- c001a4a4 T blk_dev_init
- c001a550 t blk_settings_init
- c001a59c t blk_ioc_init
- c001a5e4 t blk_softirq_init
- c001a618 t blk_iopoll_setup
- c001a64c t genhd_device_init
- c001a6fc T printk_all_partitions
- c001a950 t proc_genhd_init
- c001a9b0 t blk_scsi_ioctl_init
- c001aaa4 t bsg_init
- c001ac00 t noop_init
- c001ac20 t deadline_init
- c001ac40 t cfq_init
- c001ad14 t blk_dev_integrity_init
- c001ad5c t get_bits
- c001ae74 t nofill
- c001ae88 T bunzip2
- c001bca8 t nofill
- c001bcbc T gunzip
- c001c068 t read_int
- c001c0c4 t nofill
- c001c0d8 t rc_read
- c001c148 t rc_do_normalize
- c001c198 t rc_get_bit
- c001c244 T unlzma
- c001d2f0 T parse_header
- c001d3b4 T unlzo
- c001d8e8 T unxz
- c001dc00 T idr_init_cache
- c001dc44 t kobject_uevent_init
- c001dc6c T prio_tree_init
- c001dcc0 T radix_tree_init
- c001dd88 t random32_init
- c001de3c t random32_reseed
- c001dea4 t libcrc32c_mod_init
- c001dee4 t audit_classes_init
- c001df48 t gpiolib_debugfs_init
- c001df8c T gpiochip_reserve
- c001e060 T samsung_gpiolib_add_4bit
- c001e090 T samsung_gpiolib_add_4bit2
- c001e0c0 T samsung_gpiolib_add_2bit_chips
- c001e0f0 T samsung_gpiolib_add_4bit2_chips
- c001e128 T samsung_gpiolib_add_4bit_chips
- c001e160 T tty_init
- c001e2bc T console_init
- c001e2fc t tty_class_init
- c001e34c t pty_init
- c001e5cc t sysrq_always_enabled_setup
- c001e600 t sysrq_init
- c001e69c T vcs_init
- c001e758 T kbd_init
- c001e864 T console_map_init
- c001e8cc T vty_init
- c001eaa0 t vtconsole_class_init
- c001eb9c t con_init
- c001ee70 T uart_get_console
- c001ef6c t s3c24xx_serial_modinit
- c001efa4 t s3c24xx_serial_console_setup
- c001f164 t s3c_serial_console_init
- c001f1a4 t s3c6400_serial_init
- c001f1c8 t chr_dev_init
- c001f2b8 t random_int_secret_init
- c001f2dc t misc_init
- c001f3b0 t cn_proc_init
- c001f3f8 t sysfs_deprecated_setup
- c001f418 T devices_init
- c001f4e8 T system_bus_init
- c001f534 T buses_init
- c001f578 T classes_init
- c001f5b8 T early_platform_add_devices
- c001f620 T early_platform_cleanup
- c001f698 T early_platform_driver_probe
- c001f930 T early_platform_driver_register_all
- c001f944 T platform_bus_init
- c001f998 T early_platform_driver_register
- c001fb34 T cpu_dev_init
- c001fb50 T firmware_init
- c001fb8c T driver_init
- c001fbbc t mount_param
- c001fbe8 T devtmpfs_init
- c001fcb8 t firmware_class_init
- c001fcdc t ramdisk_size
- c001fd08 t brd_init
- c001fee4 t loop_init
- c00200a0 t max_loop_setup
- c00200cc t init_scsi
- c0020170 T scsi_init_queue
- c00202c8 T scsi_init_devinfo
- c00203a4 T scsi_init_sysctl
- c00203dc T scsi_init_procfs
- c0020460 t init_sd
- c00205ac t init_sg
- c0020704 t vcan_init_module
- c002074c t slcan_init
- c00207fc t can_dev_init
- c0020834 t probe_list2
- c00208a8 t net_olddevs_init
- c002097c t loopback_net_init
- c00209f0 t input_init
- c0020b14 t mousedev_init
- c0020b80 t sock_init
- c0020c28 T sk_init
- c0020ca4 t proto_init
- c0020cc0 t proto_init_net
- c0020cf4 T skb_init
- c0020d60 t net_ns_init
- c0020eac t net_secret_init
- c0020ed0 t sysctl_core_init
- c0020f18 t sysctl_core_net_init
- c0020f5c t dev_proc_net_init
- c0021018 t initialize_hashrnd
- c002103c T netdev_boot_setup
- c0021140 t netdev_init
- c0021198 t net_dev_init
- c0021308 T dev_mcast_init
- c0021324 t dev_mc_net_init
- c0021358 T dst_init
- c0021374 t neigh_init
- c0021400 t rtnetlink_net_init
- c0021458 T rtnetlink_init
- c0021590 t flow_cache_init_global
- c0021690 t netlink_net_init
- c00216c4 t netlink_proto_init
- c00218b0 t genl_pernet_init
- c0021910 t genl_init
- c00219ac T netfilter_init
- c0021a70 T netfilter_log_init
- c0021b78 T netfilter_queue_init
- c0021bc8 t set_rhash_entries
- c0021c10 T ip_static_sysctl_init
- c0021c34 t rt_genid_init
- c0021c68 t sysctl_route_net_init
- c0021cac t ip_rt_do_proc_init
- c0021d2c T ip_rt_init
- c0021f0c T inet_initpeers
- c0021ffc t ipv4_frags_init_net
- c0022064 T ipfrag_init
- c00220fc T ip_init
- c0022114 t set_thash_entries
- c002215c T tcp_init
- c0022458 T tcp4_proc_init
- c0022474 T tcp_v4_init
- c00224ac t tcp_sk_init
- c00224e0 t tcp4_proc_init_net
- c00224fc t tcp_congestion_default
- c0022518 T raw_proc_exit
- c0022534 t raw_init_net
- c0022568 T raw_proc_init
- c0022584 t set_uhash_entries
- c00225dc T udp_table_init
- c002271c T udp_init
- c0022790 T udp4_proc_init
- c00227ac t udp4_proc_init_net
- c00227c8 T udplite4_register
- c002286c t udplite4_proc_init_net
- c0022888 T arp_init
- c00228e8 t arp_net_init
- c002291c T icmp_init
- c0022938 t icmp_sk_init
- c0022a34 T devinet_init
- c0022aec t devinet_init_net
- c0022b94 t ipv4_mib_init_net
- c0022cf0 t inet_init
- c0022f5c T igmp_mc_proc_init
- c0022f78 t igmp_net_init
- c0022fec T ip_fib_init
- c002306c t fib_net_init
- c0023190 T fib_proc_init
- c0023234 T fib_trie_init
- c00232a0 T ping_init
- c00232dc t ping_proc_init_net
- c0023310 T ping_proc_init
- c002332c t sysctl_ipv4_init
- c00233dc t ipv4_sysctl_init_net
- c0023430 T ip_misc_proc_init
- c002344c t ip_proc_init_net
- c00234f0 t xfrm4_beet_init
- c0023510 t xfrm4_transport_init
- c0023530 t xfrm4_mode_tunnel_init
- c0023550 t ic_proto_name
- c002369c t ic_is_init_dev
- c0023704 t ic_bootp_string
- c0023744 t ic_close_devs
- c00237b0 t ic_devinet_ioctl
- c0023838 t vendor_class_identifier_setup
- c0023878 t ip_auto_config_setup
- c0023aac t nfsaddrs_config_setup
- c0023ac0 T root_nfs_parse_addr
- c0023ba4 t ip_auto_config
- c0024df8 t ic_rarp_recv
- c0024ffc t ic_bootp_recv
- c00256fc t inet_diag_init
- c00257b0 t tcp_diag_init
- c00257cc t cubictcp_register
- c0025880 T xfrm4_init
- c00258e8 T xfrm4_state_init
- c0025904 T xfrm_init
- c0025924 t xfrm_net_init
- c0025acc T xfrm_state_init
- c0025bb0 T xfrm_input_init
- c0025bf4 T xfrm_sysctl_init
- c0025c98 t af_unix_init
- c0025cfc t unix_net_init
- c0025d5c T unix_sysctl_register
- c0025dc8 t packet_init
- c0025e1c t packet_net_init
- c0025e54 t can_init
- c0025f58 t raw_module_init
- c0025fa4 t bcm_module_init
- c0026018 t cfg80211_init
- c00260f0 T regulatory_init
- c00261dc t lib80211_init
- c0026204 t wext_pernet_init
- c002622c t wireless_nlevent_init
- c0026248 T wext_proc_init
- c002627c t ieee80211_init
- c00262c8 T rc80211_minstrel_init
- c00262e4 T rc80211_minstrel_ht_init
- c00263b4 t sysctl_init
- c002640c t sysctl_net_init
- c0026438 t init_dns_resolver
- c0026580 t __lookup_processor_type
- c00265b8 t __lookup_processor_type_data
- c00265c4 t __error_p
- c00265e0 t str_p1
- c0026617 t str_p2
- c002661c t __error
- c0026624 T calibrate_delay
- c002681c t dbg_reset_notify
- c0026858 t __v6_setup
- c0026898 t v6_crval
- c00268a0 T init_idle_bootup_task
- c00268bc T init_idle
- c0026918 W idle_regs
- c002693c T fork_idle
- c00269cc t cpu_callback
- c0026abc t timer_cpu_notify
- c0026c50 t hrtimer_cpu_notify
- c0026cac t perf_cpu_notify
- c0026d68 t ratelimit_handler
- c0026d80 T register_cpu
- c0026ddc t flow_cache_cpu_prepare
- c0026e64 t flow_cache_cpu
- c0026f10 T init_currently_empty_zone
- c0027040 T memmap_init_zone
- c0027164 T init_per_zone_wmark_min
- c0027214 T __free_pages_bootmem
- c00272c8 T mminit_verify_page_links
- c0027334 T __proc_info_begin
- c0027334 t __v6_proc_info
- c0027334 T _einittext
(3)真正的驻留在内存中的内核内代码段
从脚本上来看,所有.text开始,.etext结束区间的段都是内核代码段:
- .text : { /* Real text segment */
- _text = .; /* Text and read-only data */
- __exception_text_start = .;
- *(.exception.text)
- __exception_text_end = .;
- IRQENTRY_TEXT
- TEXT_TEXT
- SCHED_TEXT
- LOCK_TEXT
- KPROBES_TEXT
- #ifdef CONFIG_MMU
- *(.fixup)
- #endif
- *(.gnu.warning)
- *(.rodata)
- *(.rodata.*)
- *(.glue_7)
- *(.glue_7t)
- . = ALIGN(4);
- *(.got) /* Global offset table */
- ARM_CPU_KEEP(PROC_INFO)
- }
-
- RO_DATA(PAGE_SIZE)
-
- #ifdef CONFIG_ARM_UNWIND
- /*
- * Stack unwinding tables
- */
- . = ALIGN(8);
- .ARM.unwind_idx : {
- __start_unwind_idx = .;
- *(.ARM.exidx*)
- __stop_unwind_idx = .;
- }
- .ARM.unwind_tab : {
- __start_unwind_tab = .;
- *(.ARM.extab*)
- __stop_unwind_tab = .;
- }
- #endif
-
- _etext = .; /* End of text and rodata section */
这些段中的代码都是事实在在的内核函数。
(4)已经初始化的data数据段:
- .data : AT(__data_loc) {
- _data = .; /* address in memory */
- _sdata = .;
-
- /*
- * first, the init task union, aligned
- * to an 8192 byte boundary.
- */
- INIT_TASK_DATA(THREAD_SIZE)
-
- #ifdef CONFIG_XIP_KERNEL
- . = ALIGN(PAGE_SIZE);
- __init_begin = .;
- INIT_DATA
- ARM_EXIT_KEEP(EXIT_DATA)
- . = ALIGN(PAGE_SIZE);
- __init_end = .;
- #endif
-
- NOSAVE_DATA
- CACHELINE_ALIGNED_DATA(32)
- READ_MOSTLY_DATA(32)
-
- /*
- * The exception fixup table (might need resorting at runtime)
- */
- . = ALIGN(32);
- __start___ex_table = .;
- #ifdef CONFIG_MMU
- *(__ex_table)
- #endif
- __stop___ex_table = .;
-
- /*
- * and the usual data section
- */
- DATA_DATA
- CONSTRUCTORS
-
- _edata = .;
(5)紧接着以初始化的.data段的是.bss,未经初始化的内核数据段。
- BSS_SECTION(0, 0, 0)
- _end = .;