From fe8ed935e1163946a888dc2d36e5af37cb417474 Mon Sep 17 00:00:00 2001 From: jaby Date: Sun, 28 Aug 2022 19:35:30 +0200 Subject: [PATCH] Linker Script for PSX --- lib/pcsx-redux/default.ld | 2 +- lib/pcsx-redux/ps-exe.ld | 32 ++++++++++++++++++++++++------ src/Library/src/BootLoader/start.c | 4 +++- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/lib/pcsx-redux/default.ld b/lib/pcsx-redux/default.ld index 031fbe69..d200a6d1 100644 --- a/lib/pcsx-redux/default.ld +++ b/lib/pcsx-redux/default.ld @@ -1 +1 @@ -__heap_base = __bss_end; \ No newline at end of file +__heap_base = __bss_end; \ No newline at end of file diff --git a/lib/pcsx-redux/ps-exe.ld b/lib/pcsx-redux/ps-exe.ld index db24b82a..bc5bb41f 100644 --- a/lib/pcsx-redux/ps-exe.ld +++ b/lib/pcsx-redux/ps-exe.ld @@ -45,10 +45,33 @@ __dcache_top = ORIGIN(dcache) + LENGTH(dcache); __bss_len = (__bss_end - __bss_start); __ftext_len = (__ftext_end - __ftext_start); -__fdata_len = (__fdata_end - __fdata_start); +__fdata_len = (__planschi_end - __fdata_start); __stack_start = ORIGIN(ram) + LENGTH(ram); +__heap_base = __planschi_end; + +SECTIONS { + __planschi_start = .; + OVERLAY __bss_end : NOCROSSREFS SUBALIGN(4) + { + .planschi + { + *libJabyEngine.a:start.o(.text.startup._GLOBAL__*) + *libJabyEngine.a:start.o(.ctors) + *libJabyEngine.a:start.o(.text.*) + *libJabyEngine.a:start.o(.rodata*) + *libJabyEngine.a:start.o(.sdata*) + *libJabyEngine.a:start.o(.data*) + *libJabyEngine.a:start.o(.sbss*) + *libJabyEngine.a:start.o(.bss*) + } + } + /*Only needed for the PSX BIOS to load the entire game*/ + . = ALIGN(2048); + __planschi_end = .; +} + SECTIONS { .PSX_EXE_Header : { /* @@ -164,14 +187,12 @@ SECTIONS { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) *(.got.plt) *(.got) - /* pad file to be a multiple of 2048 bytes. Needed for loading from CD-ROM. */ - . = ALIGN(2048); } > ram - __data_end = .; + __data_end = .; __fdata_end = .; __bss_start = .; - .sbss (NOLOAD) : { + .sbss : { *(.dynsbss) *(.sbss .sbss.* .gnu.linkonce.sb.*) *(.scommon) @@ -182,7 +203,6 @@ SECTIONS { . = ALIGN(4); __bss_end = .; - __heap_start = __heap_base; . = ADDR(.text) - 0x800; diff --git a/src/Library/src/BootLoader/start.c b/src/Library/src/BootLoader/start.c index 30b03799..bf4f5e21 100644 --- a/src/Library/src/BootLoader/start.c +++ b/src/Library/src/BootLoader/start.c @@ -1,6 +1,8 @@ #include +int x = 0; + void _start() { //call main here - printf("Hello Planschbecken c:\n"); + printf("Hello Planschbecken c: %i\n", x); } \ No newline at end of file