Code: Select all
ENTRY(kernelCompatibilityModeStart);
SECTIONS {
. = 0x80000000; /* lowerhalf origin */
.lowerhalf : ALIGN(0x1000) {
*(.lowerhalf);
}
. = 0xffffffff80000000; /* higherhalf origin */
.GDT64 : ALIGN(0x1000) {
*(.GDT64);
}
.IDT64 : ALIGN(0x1000) {
*(.IDT64);
}
.TSS64 : ALIGN(0x1000) {
*(.TSS64);
}
.KERNELSTACK : ALIGN(0x1000) {
*(.KERNELSTACK);
}
.ISTs : ALIGN(0x1000) {
*(.ISTs);
}
.text : ALIGN(0x1000) {
*(.text);
}
.data : ALIGN(0x1000) {
*(.data);
}
.rodata : ALIGN(0x1000) {
*(.rodata*);
}
.bss : ALIGN(0x1000) {
*(COMMON);
*(.bss);
}
}
Code: Select all
Elf file type is EXEC (Executable file)
Entry point 0x80000000
There are 3 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000001000 0x0000000080000000 0x0000000080000000
0x0000000000000030 0x0000000000000030 R 0x1000
LOAD 0x0000000000002000 0xffffffff80000000 0xffffffff80000000
0x0000000000026718 0x0000000000026718 R E 0x1000
LOAD 0x0000000000029000 0xffffffff80027000 0xffffffff80027000
0x0000000000004954 0x00000000000053d8 RW 0x1000
Section to Segment mapping:
Segment Sections...
00 .lowerhalf
01 .GDT64 .IDT64 .TSS64 .KERNELSTACK .ISTs .text
02 .data .ctors .rodata .eh_frame .bss
1. the `.text` section gets bundled up with other sections like `.GDT64` and `.KERNELSTACK`
2. `.lowerhalf` should have `RE` attributes instead of just `R`
3. all `.data`, `.ctors`, and `.rodata` end up with the `RW` flags.
I tried using the `MEMORY` directive but that results in a load of linker errors or warnings and doesn't give the desired output.
I'd like for the sections to have appropriate `RWE` attributes so I can create my paging entries accordingly.
How do I add the correct attributes?