feat: fix some linker stuff

This commit is contained in:
Katharina 2026-06-28 22:51:18 +02:00
parent cb33372066
commit e028f9ba63
2 changed files with 30 additions and 5 deletions

View file

@ -19,7 +19,7 @@ $(object_files): $(object_dir)%.o : $(source_dir)%
kernel.bin: $(object_files)
@mkdir -p $(output_dir)
@echo "Linking kernel"
@$(LD) --build-id=none --no-relax --no-warn-rwx-segments -nostdlib -o $(output_dir)/kernel.bin -T $(linker_script) $(object_files)
@$(LD) --build-id=none --no-relax --no-warn-rwx-segments --orphan-handling=error -nostdlib -o $(output_dir)/kernel.bin -T $(linker_script) $(object_files)
@echo "Disassembling kernel"
@objdump -dC $(output_dir)/kernel.bin > $(output_dir)/kernel.asm
@objdump -DC $(output_dir)/kernel.bin > $(output_dir)/kernel_full.asm

View file

@ -33,12 +33,14 @@ SECTIONS
} > START_MEMORY_PV
.text : AT(ADDR(.text) - high_base) {
__text_start__ = .;
*(EXCLUDE_FILE(*trampoline*) .text)
*(EXCLUDE_FILE(*trampoline*) .text .text.*)
*(EXCLUDE_FILE(*trampoline*) .iplt)
__text_end__ = .;
} > HIGH_KERNEL_V
.rodata : AT(ADDR(.rodata) - high_base) {
__rodata_start__ = .;
*(EXCLUDE_FILE(*trampoline*) .rodata)
*(EXCLUDE_FILE(*trampoline*) .rodata .rodata.*)
. = ALIGN(8);
__reserved_ranges_start__ = .;
KEEP(*(.reserved_ranges))
__reserved_ranges_end__ = .;
@ -50,12 +52,13 @@ SECTIONS
} > HIGH_KERNEL_V
.data : AT(ADDR(.data) - high_base) {
__data_start__ = .;
*(EXCLUDE_FILE(*trampoline*) .data)
*(EXCLUDE_FILE(*trampoline*) .data .data.*)
*(EXCLUDE_FILE(*trampoline*) .got .got.plt .igot.plt .data.rel.ro .data.rel.ro.*)
__data_end__ = .;
} > HIGH_KERNEL_V
.bss (NOLOAD) : AT(ADDR(.bss) - high_base) {
__bss_start__ = .;
*(EXCLUDE_FILE(*trampoline*) .bss)
*(EXCLUDE_FILE(*trampoline*) .bss .bss.*)
__bss_end__ = .;
} > HIGH_KERNEL_V
@ -83,11 +86,33 @@ SECTIONS
__trampoline_bss_end__ = .;
} > TRAMPOLINE_PV
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_line_str 0 : { *(.debug_line_str) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_loclists 0 : { *(.debug_loclists) }
.debug_macinfo 0 : { *(.debug_macinfo) }
.debug_macro 0 : { *(.debug_macro) }
.debug_ranges 0 : { *(.debug_ranges) }
.debug_rnglists 0 : { *(.debug_rnglists) }
.debug_addr 0 : { *(.debug_addr) }
.debug_str_offsets 0 : { *(.debug_str_offsets) }
.debug_names 0 : { *(.debug_names) }
.debug_types 0 : { *(.debug_types) }
/DISCARD/ : {
*(.comment)
*(.eh_frame)
*(.note)
*(.note.gnu.build-id)
*(.note.GNU-stack)
*(.rela*)
}
}