I had a problem switching from mapping the whole memory to mapping the sections that i provide by linker-symboles.
When calling some functions under certain circumstances, i got a triple-fault.
Then i looked through my section-sizes and found that there were like 0x2000 missing between .rodata and .bss.
So i did an objdump -h of my kernel and found three extra sections: .eh_frame, .rodata.str1.1 and .rodata.str1.8
I added them to .rodata like so:
Code: Select all
.rodata ALIGN(0x1000) : AT(ADDR(.rodata) - HVMA)
{
_rodata_start = .;
*(.rodata)
*(.eh_frame)
*(.rodata.str1.1)
*(.rodata.str1.8)
_rodata_end = .;
}
And what are the other two .rodata-sections?
Thanks for your help!
EDIT: And why do i get a triple-fault when adding the NX-Bit to .data and .bss?
EDIT2: I think i found the problem for .data... I'm calling start_dtors in the .data-section, aren't i?
For reference, the whole linker-file:
Code: Select all
OUTPUT_FORMAT(elf64-x86-64)
ENTRY(start)
HVMA = 0xFFFFFF0000000000;
SECTIONS
{
. = 1M;
_start = . + HVMA;
_bin_start = . + HVMA;
.init :
{
*(.initl)
}
. += HVMA;
.text ALIGN(0x1000) : AT(ADDR(.text) - HVMA)
{
*(.inith)
*(.text)
}
_bin_end = .;
.data ALIGN(0x1000) : AT(ADDR(.data) - HVMA)
{
_data_start = .;
start_ctors = .;
*(.ctor*)
end_ctors = .;
start_dtors = .;
*(.dtor*)
end_dtors = .;
*(.data)
_data_end = .;
}
.rodata ALIGN(0x1000) : AT(ADDR(.rodata) - HVMA)
{
_rodata_start = .;
*(.rodata)
*(.eh_frame)
*(.rodata.str1.1)
*(.rodata.str1.8)
_rodata_end = .;
}
.bss ALIGN(0x1000) : AT(ADDR(.bss) - HVMA)
{
_bss_start = .;
*(COMMON)
*(.bss)
_bss_end = .;
}
_end = .;
}