Code: Select all
OUTPUT_FORMAT(elf32-i386)
ENTRY(kmain)
SECTIONS {
. = 0xC0000000;
__begin = .;
.text : AT(0x100000)
{
*(.text.entry) /* Ensure .text.entry appears first */
*(.text*)
}
.user 0x0 : AT(0x100000 + SIZEOF (.text)) /*I WANT TO ALIGN THIS LOAD ADDRESS TOO!!!
{
__user_load_begin = LOADADDR(.user);
*(.user);
__user_load_end = LOADADDR(.user) + SIZEOF(.user);
}
.data ADDR(.text) + SIZEOF(.text) : AT(0x100000 + SIZEOF(.user) + SIZEOF(.text))
{
*(.rodata)
*(.data)
}
__debug =.;
.bss : SUBALIGN(16)
{
__bss_start = .;
*(COMMON) /* all COMMON sections from all files */
*(.bss) /* all BSS sections from all files */
}
. = ALIGN(4k);
__VGA_text_memory = .;
/DISCARD/ : { /* Remove Unneeded sections */
*(.eh_frame);
*(.comment);
}
__end = .;
}
The above linker script is ALMOST what I want. There are a few issues.
I don't use the location counter (.) here. Surely, it is not advisable to do that. I manually fill in the virtual and physical addresses of .user and .text.
The other issue is that I need to align the load address as well as virtual address of .user and I'm not sure what's the best way to do that.
Right now, the load address is LOADADDR(.text) + SIZEOF(.text). Maybe I want SIZEOF(.text) to be 4k aligned