Starnge LD linker script result
Posted: Wed Jun 10, 2015 9:12 am
Hello everyone. In my kernel I use a linker script to describe kernel's memory layout. The script is:
And in C code I printed out addresses of those locations, the result is:
("kernel_stack" and "pml4t" are two data structures located in bss segment)
That's strange. I thought "kernel_end" should be the largest number, but tended out to be same as "kernel_start". And, "text_start" is different from "kernel_start", even text is the first segment. And each segments' start and end address are all same.
Code: Select all
OUTPUT_FORMAT(binary)
SECTIONS {
. = 1M;
kernel_load_addr = .;
.text BLOCK(4K) : ALIGN(4K) {
kernel_text_start = .;
*(.boot)
*(.text)
kernel_text_end = .;
} = 0x90 /* NOP */
.data BLOCK(4K) : ALIGN(4K) {
kernel_data_start = .;
*(.rodata)
*(.data)
kernel_data_end = .;
} = 0
.bss BLOCK(4K) : ALIGN(4K) {
kernel_bss_start = .;
*(COMMON)
*(.bss)
kernel_bss_end = .;
} = 0
kernel_end = .;
}
("kernel_stack" and "pml4t" are two data structures located in bss segment)
That's strange. I thought "kernel_end" should be the largest number, but tended out to be same as "kernel_start". And, "text_start" is different from "kernel_start", even text is the first segment. And each segments' start and end address are all same.