Skip to content

Commit

Permalink
slight modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
brvtalcake committed Oct 26, 2024
1 parent 4e547f7 commit f3f5eca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions scripts/gensectioninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def main() -> int:
section_ldsyms = Template(
"""
/* --- SECTIONINFO START: ${section} --- */
zerOS_${section}_start = ADDR(.${section});
zerOS_${section}_end = ADDR(.${section}) + SIZEOF(.${section});
zerOS_${section}_start = ABSOLUTE(ADDR(.${section}));
zerOS_${section}_end = ABSOLUTE(ADDR(.${section})) + SIZEOF(.${section});
zerOS_${section}_size = SIZEOF(.${section});
/* --- SECTIONINFO END: ${section} --- */
"""
Expand Down
31 changes: 18 additions & 13 deletions zerOS/linker-x86_64.ld.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* TODO: Write a custom bootloader */
/* TODO: Write a custom EFI-stub */

/* Tell the linker that we want an x86_64 ELF64 output file */
OUTPUT_FORMAT(elf64-x86-64)
Expand All @@ -17,7 +17,7 @@ PHDRS
rodata PT_LOAD;
data PT_LOAD;
dynamic PT_DYNAMIC;
/* TODO: Add support for "TLS" or per-cpu variables / sections */
percpu PT_LOAD;
}

SECTIONS
Expand All @@ -30,9 +30,7 @@ SECTIONS
/* base load address. */
. = 0xffffffff80000000 + SIZEOF_HEADERS;

.start_kern : {
zerOS_kernel_start = .;
} :rodata
zerOS_kernel_start = ABSOLUTE(.);

/* Emit zerOS_<section_name>_start and zerOS_<section_name>_end symbols for each section. */

Expand All @@ -57,6 +55,12 @@ SECTIONS
!!!__GENSECTION_FILL__!!!
} :rodata

. = ALIGN(CONSTANT(MAXPAGESIZE));

.percpu : {
*(.percpu .percpu.*)
} :percpu

/* Move to the next memory page for .data */
. = ALIGN(CONSTANT(MAXPAGESIZE));

Expand All @@ -70,10 +74,7 @@ SECTIONS
KEEP(*(.requests_end_marker))
} :data

/* Dynamic section for relocations, both in its own PHDR and inside data PHDR. */
/*.dynamic : { */
/* *(.dynamic) */
/*} :data :dynamic*/
. = ALIGN(CONSTANT(MAXPAGESIZE));

/* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */
/* unnecessary zeros will be written to the binary. */
Expand All @@ -84,9 +85,8 @@ SECTIONS
*(COMMON)
} :data

.end_kern : {
zerOS_kernel_end = .;
} :rodata
zerOS_kernel_end = ABSOLUTE(.);


/* Discard .note.* and .eh_frame* since they may cause issues on some hosts. */
/* Also discard the program interpreter section since we do not need one. This is */
Expand All @@ -97,4 +97,9 @@ SECTIONS
*(.note .note.*)
*(.interp)
}
}
}

NOCROSSREFS_TO(.text, .bootcode)

ASSERT( ADDR(zerOS_kernel_start) == 0xffffffff80000000 + SIZEOF_HEADERS, "zerOS_kernel_start is not at the correct VMA")
ASSERT(LOADADDR(zerOS_kernel_start) == 0xffffffff80000000 + SIZEOF_HEADERS, "zerOS_kernel_start is not at the correct LMA")

0 comments on commit f3f5eca

Please sign in to comment.