Fix linker RWX warning

This commit is contained in:
2025-07-20 23:17:40 +02:00
parent a5ef7a0906
commit 76b4979067
4 changed files with 23 additions and 19 deletions

View File

@@ -350,7 +350,7 @@ rule '.elna.o' => ->(match) {
architecture, *path_components = relative_from_tmp(match).to_a
path_components[-1] = path_components.last.ext('')
[File.join(path_components), TMP + architecture]
[File.join('source', path_components), TMP + architecture]
} do |t|
options = BuildTarget.new relative_from_tmp(t.name).first
compiler = options.rootfs + "bin/#{options.target}-gcc"
@@ -366,10 +366,11 @@ rule 'kernel.elf' => ->(match) {
arch_objects = FileList["arch/#{instruction_set}/*.s"]
.map { |source| Pathname.new(source).relative_path_from("arch/#{instruction_set}").sub_ext('.s.o') }
.map { |source| TMP + architecture + source }
.map(&:to_path)
source_objects = FileList['source/*.elna']
.map { |source| Pathname.new(source).relative_path_from('source').sub_ext('.elna.o') }
objects = (arch_objects + source_objects).map { |source| (TMP + architecture + source).to_s }
arch_objects + FileList['*.elna'].map { |source| (TMP + architecture + source).to_path + '.o' } << 'kernel.ld'
objects << "arch/#{instruction_set}/kernel.ld"
} do |t|
options = BuildTarget.new relative_from_tmp(t.name).first
compiler = options.rootfs + "bin/#{options.target}-gcc"

View File

@@ -1,25 +1,28 @@
OUTPUT_ARCH("riscv")
OUTPUT_FORMAT("elf32-littleriscv")
ENTRY(boot)
ENTRY(_entry)
SECTIONS {
. = 0x80200000;
__kernel_base = .;
.text :{
KEEP(*(.text.boot));
*(.text .text.*);
PHDRS {
text PT_LOAD FLAGS(5);
data PT_LOAD FLAGS(6);
}
.rodata : ALIGN(4) {
SECTIONS {
.text 0x80200000 : {
__kernel_base = .;
KEEP(*(.text.boot));
*(.text .text.*);
} :text
.rodata : ALIGN(16) {
*(.rodata .rodata.*);
}
.data : ALIGN(4) {
.data : ALIGN(16) {
*(.data .data.*);
}
} :data
.bss : ALIGN(4) {
.bss : ALIGN(16) {
__bss = .;
*(.bss .bss.* .sbss .sbss.*);
__bss_end = .;
@@ -29,6 +32,6 @@ SECTIONS {
. += 128 * 1024; /* 128KB */
__stack_top = .;
. = ALIGN(4096);
. = ALIGN(CONSTANT(MAXPAGESIZE));
__free_ram = .;
}

View File

@@ -1,4 +1,4 @@
.global kernel_main, __bss, __bss_end, __stack_top
.global _entry, __bss, __bss_end, __stack_top
.section .rodata
@@ -215,7 +215,7 @@ panic:
ret
.section .text.boot
boot:
_entry:
la t0, __stack_top
mv sp, t0 # Set the stack pointer