Add relocs back to the mix

This commit is contained in:
Mc-muffin
2026-07-29 13:55:08 -05:00
committed by Timothy O'Barr
parent bf185dbf0b
commit 8095830634
3 changed files with 2190 additions and 2161 deletions
+14
View File
@@ -1,6 +1,7 @@
MEMORY
{
main (RWX) : ORIGIN = 0x100000, LENGTH = 0x0
heap (RW) : ORIGIN = AFTER(main), LENGTH = 0x0
}
KEEP_SECTION
@@ -14,6 +15,12 @@ KEEP_SECTION
SECTIONS
{
# define for crt0
_heap_size = 0x0149CC80;
_stack = 0x01F00000;
_stack_size = 0x00100000;
# define for lcf
_align_segment = 0x80;
.main :
{
@@ -24,4 +31,11 @@ SECTIONS
. = ALIGN(0x80);
} > main
.heap :
{
# to get the address for heap
end = .;
_end = .;
} > heap
}
File diff suppressed because it is too large Load Diff
+14 -1
View File
@@ -211,7 +211,7 @@ def build_stuff(
ninja = ninja_syntax.Writer(open(str(ROOT / config_dir / "build.ninja"), "w"), width=9999)
# Rules
ld_args = "-map -sym on,elf -noinhibit-exec -main ENTRYPOINT -o $out $lcf $objects"
ld_args = "-map -sym on,elf -noinhibit-exec -main _start -o $out $lcf $objects"
ld = Path("..", (Path("tools") / "cc" / COMPILER / "mwldps2.exe"))
cpp = Path("..", (Path("tools") / "cc" / COMPILER / "mwccps2.exe"))
@@ -796,6 +796,19 @@ def generate_lcf():
f"\t\t__{section_type[1:]}_start = .;",
f"\t\tALIGNALL(0x{alignment:X});",
]
if section_type == ".sdata":
block = [
"\t\t_gp\t= ALIGN(128) + 0x7FF0;",
"",
] + block
if section_type == ".sbss":
block = [
"\t\t_fbss\t= .;",
"",
] + block
for entry in objects:
alignment = entry.segment.ld_align_segment_start
if alignment is not None: