Share bss section with planschi section
This commit is contained in:
parent
6ff067587d
commit
5c40ef119e
|
@ -7,7 +7,7 @@
|
|||
#include "../cd_file_types.hpp"
|
||||
#include "file_processor.hpp"
|
||||
|
||||
extern "C" uint32_t __heap_base;
|
||||
extern "C" uint32_t __heap_start;
|
||||
|
||||
namespace JabyEngine {
|
||||
class CDFileProcessor {
|
||||
|
@ -20,7 +20,7 @@ namespace JabyEngine {
|
|||
size_t sector_count = 0;
|
||||
|
||||
static constexpr BufferConfiguration new_default() {
|
||||
return {&__heap_base, BufferConfiguration::MediumSectorCount};
|
||||
return {&__heap_start, BufferConfiguration::MediumSectorCount};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ CCFLAGS += -DJABYENGINE_$(TV_FORMAT)
|
|||
#Linker flags
|
||||
LDFLAGS_release += -Os
|
||||
|
||||
LDFLAGS_all += -Wl,-Map=$(TARGET).map -nostdlib -T$(AUTO_OVERLAY_DIR)/Overlays.ld -T$(JABY_ENGINE_DIR)/lib/psexe.ld -static -Wl,--gc-sections -Wl,--build-id=none -Wl,--no-check-sections
|
||||
LDFLAGS_all += -Wl,-Map=$(TARGET).map -nostdlib -T$(JABY_ENGINE_DIR)/lib/psexe.ld -static -Wl,--gc-sections -Wl,--build-id=none -Wl,--no-check-sections
|
||||
LDFLAGS_all += $(ARCHFLAGS) -Wl,--oformat=$(FORMAT)
|
||||
LDFLAGS_all += $(LDFLAGS_$(BUILD_PROFILE))
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ OVERLAY_TARGET = $(foreach ovl, $(OVERLAYSECTION), $(OUTPUT_DIR)/Overlay$(ovl))
|
|||
|
||||
#Linking rule
|
||||
$(TARGET).elf: $(OBJS) $(JABY_ENGINE_LIB_DIR)/lib$(JABY_ENGINE_LIB_NAME).a $(AUTO_OVERLAY_DIR)/Overlays.ld
|
||||
$(LD) -o $(TARGET).elf $(LDFLAGS_all) $(LDFLAGS) $(OBJS) -L$(JABY_ENGINE_LIB_DIR) -l$(JABY_ENGINE_LIB_NAME) $(LIBS)
|
||||
$(LD) -o $(TARGET).elf $(LDFLAGS_all) $(LDFLAGS) $(OBJS) -L$(JABY_ENGINE_LIB_DIR) -L$(AUTO_OVERLAY_DIR) -l$(JABY_ENGINE_LIB_NAME) $(LIBS)
|
||||
|
||||
#Strips the psexe
|
||||
$(TARGET).psexe: $(TARGET).elf
|
||||
|
|
110
lib/psexe.ld
110
lib/psexe.ld
|
@ -25,7 +25,6 @@ SOFTWARE.
|
|||
*/
|
||||
|
||||
OUTPUT_FORMAT("binary")
|
||||
|
||||
EXTERN(_ZN10JabyEngine5startEv)
|
||||
ENTRY(_ZN10JabyEngine5startEv)
|
||||
|
||||
|
@ -34,7 +33,6 @@ TLOAD_ADDR = DEFINED(TLOAD_ADDR) ? TLOAD_ADDR : 0x80010000;
|
|||
MEMORY {
|
||||
loader : ORIGIN = (TLOAD_ADDR - 0x800), LENGTH = 2048
|
||||
ram (rwx) : ORIGIN = 0x80010000, LENGTH = 2M - 0x10000
|
||||
ram2 (rwx) : ORIGIN = 0x80010000, LENGTH = 2M - 0x10000
|
||||
dcache : ORIGIN = 0x1f800000, LENGTH = 0x400
|
||||
}
|
||||
|
||||
|
@ -62,38 +60,39 @@ SECTIONS {
|
|||
}
|
||||
|
||||
/*Overlay sections created by mkoverlay*/
|
||||
INCLUDE Overlays.ld
|
||||
SECTIONS {
|
||||
.planschi __bss_end : SUBALIGN(4)
|
||||
.planschi __engine_bss_end : SUBALIGN(4)
|
||||
{
|
||||
__planschi_start = .;
|
||||
__boot_loader_start = .;
|
||||
|
||||
*libJabyEngine.a:*_boot.o(.text.startup._GLOBAL__*)
|
||||
*libJabyEngine_*.a:*_boot.o(.text.startup._GLOBAL__*)
|
||||
*_boot.o(.text.startup._GLOBAL__*)
|
||||
*libJabyEngine.a:*_boot.o(.ctors)
|
||||
*libJabyEngine_*.a:*_boot.o(.ctors)
|
||||
*_boot.o(.ctors)
|
||||
|
||||
*libJabyEngine.a:*_boot.o(.text.*)
|
||||
*libJabyEngine_*.a:*_boot.o(.text.*)
|
||||
*_boot.o(.text.*)
|
||||
*libJabyEngine.a:*_boot.o(.rodata*)
|
||||
*libJabyEngine_*.a:*_boot.o(.rodata*)
|
||||
*_boot.o(.rodata*)
|
||||
*libJabyEngine.a:*_boot.o(.sdata*)
|
||||
*libJabyEngine_*.a:*_boot.o(.sdata*)
|
||||
*_boot.o(.sdata*)
|
||||
*libJabyEngine.a:*_boot.o(.data*)
|
||||
*libJabyEngine_*.a:*_boot.o(.data*)
|
||||
*_boot.o(.data*)
|
||||
*libJabyEngine.a:*_boot.o(.sbss*)
|
||||
*libJabyEngine_*.a:*_boot.o(.sbss*)
|
||||
*_boot.o(.sbss*)
|
||||
*libJabyEngine.a:*_boot.o(.bss*)
|
||||
*libJabyEngine_*.a:*_boot.o(.bss*)
|
||||
*_boot.o(.bss*)
|
||||
*libJabyEngine.a:*_boot.o(*)
|
||||
*libJabyEngine_*.a:*_boot.o(*)
|
||||
*_boot.o(*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__boot_loader_end = .;
|
||||
/*Only needed for the PSX BIOS to load the entire game*/
|
||||
. = ALIGN(2048);
|
||||
__planschi_end = .;
|
||||
}
|
||||
__planschi_end = .;
|
||||
}
|
||||
}
|
||||
|
||||
SECTIONS {
|
||||
|
@ -141,37 +140,36 @@ SECTIONS {
|
|||
. = . + 1992;
|
||||
} > loader
|
||||
|
||||
__persistent_lbas_start = ABSOLUTE(.);
|
||||
.persistent_lbas TLOAD_ADDR : {
|
||||
__persistent_lbas = .;
|
||||
KEEP(*(.header.lbas))
|
||||
__persistent_lbas_start = .;
|
||||
__persistent_lbas = .;
|
||||
KEEP(*(.header.lbas))
|
||||
. = ALIGN(4);
|
||||
__persistent_lbas_end = .;
|
||||
} > ram
|
||||
. = ALIGN(4);
|
||||
__persistent_lbas_end = ABSOLUTE(.);
|
||||
|
||||
__ftext_start = ABSOLUTE(.);
|
||||
.text : {
|
||||
*(.start)
|
||||
*(.init)
|
||||
KEEP (*(SORT_NONE(.fini)))
|
||||
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
|
||||
*(.text.exit .text.exit.*)
|
||||
*(.text.startup .text.startup.*)
|
||||
*(.text.hot .text.hot.*)
|
||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
||||
__text_start = .;
|
||||
*(.start)
|
||||
*(.init)
|
||||
KEEP (*(SORT_NONE(.fini)))
|
||||
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
|
||||
*(.text.exit .text.exit.*)
|
||||
*(.text.startup .text.startup.*)
|
||||
*(.text.hot .text.hot.*)
|
||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
||||
|
||||
. = ALIGN(16);
|
||||
KEEP(*(.init))
|
||||
. = ALIGN(16);
|
||||
KEEP(*(.fini))
|
||||
. = ALIGN(16);
|
||||
KEEP(*(.init))
|
||||
. = ALIGN(16);
|
||||
KEEP(*(.fini))
|
||||
__text_end = .;
|
||||
} > ram
|
||||
|
||||
. = ALIGN(16);
|
||||
__text_end = .;
|
||||
__ftext_end = ABSOLUTE(.);
|
||||
|
||||
__fdata_start = ABSOLUTE(.);
|
||||
|
||||
.rodata : {
|
||||
*(.rodata .rodata.* .rdata .rdata.* .gnu.linkonce.r.*)
|
||||
. = ALIGN(16);
|
||||
|
@ -210,33 +208,43 @@ SECTIONS {
|
|||
*(.rodata1)
|
||||
} > ram
|
||||
|
||||
__data_start = .;
|
||||
.data : {
|
||||
*(.a0table)
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
*(.data1)
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.*)
|
||||
*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
__data_start = .;
|
||||
*(.a0table)
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
*(.data1)
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.*)
|
||||
*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
|
||||
*(.got.plt)
|
||||
*(.got)
|
||||
__data_end = .;
|
||||
} > ram
|
||||
|
||||
__data_end = .;
|
||||
.engine_bss : {
|
||||
__engine_bss_start = .;
|
||||
*libJabyEngine_*.a:*(.dynsbss)
|
||||
*libJabyEngine_*.a:*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
||||
*libJabyEngine_*.a:*(.scommon)
|
||||
*libJabyEngine_*.a:*(.dynbss)
|
||||
*libJabyEngine_*.a:*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
*libJabyEngine_*.a:*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__engine_bss_end = .;
|
||||
} > ram
|
||||
__fdata_end = .;
|
||||
__bss_start = .;
|
||||
.bss : {
|
||||
|
||||
.bss __persistent_overlay_end (NOLOAD) : {
|
||||
__bss_start = .;
|
||||
*(.dynsbss)
|
||||
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
||||
*(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end = .;
|
||||
} > ram
|
||||
|
||||
. = ALIGN(4);
|
||||
__bss_end = .;
|
||||
__heap_start = __heap_base;
|
||||
|
||||
/*. = ADDR(.text) - 0x800;*/
|
||||
__heap_start = __bss_end;
|
||||
__end = .;
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
include ../../lib/RebuildTarget.mk
|
||||
JABY_ENGINE_DIR = ../../
|
||||
|
||||
ARTIFACT = libJabyEngine_$(TV_FORMAT)
|
||||
|
|
|
@ -3,6 +3,13 @@
|
|||
#include <PSX/System/IOPorts/dma_io.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" uint32_t __heap_start;
|
||||
extern "C" uint32_t __bss_start;
|
||||
extern "C" uint32_t __bss_end;
|
||||
extern "C" uint32_t __bss_len;
|
||||
extern "C" uint32_t __planschi_start;
|
||||
extern "C" uint32_t __planschi_end;
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace boot {
|
||||
namespace Start {
|
||||
|
@ -29,6 +36,9 @@ namespace JabyEngine {
|
|||
|
||||
void start() {
|
||||
printf("Starting Planschbecken\n");
|
||||
printf("Heap starts @0x%p\n", &__heap_start);
|
||||
printf("BSS from 0x%p to 0x%p (%u)\n", &__bss_start, &__bss_end, __bss_len);
|
||||
printf("PLANSCHI from 0x%p to 0x%p\n", &__planschi_start, &__planschi_end);
|
||||
boot::Start::setup();
|
||||
|
||||
printf("Running main...\n");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "mkoverlay"
|
||||
version = "1.1.1"
|
||||
version = "1.5.0"
|
||||
edition = "2021"
|
||||
|
||||
[profile.release]
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
use super::super::types::{OverlayDesc, OverlaySection};
|
||||
use tool_helper::{Error, format_if_error, Output};
|
||||
use tool_helper::{Error, Output};
|
||||
use std::io::Write;
|
||||
|
||||
const OVERLAY_DEFAULT_START:&'static str = "__planschi_start"; // < will probably be "__boot_loader_start" later
|
||||
|
||||
macro_rules! section_end_name_template {
|
||||
() => {
|
||||
"__{}_end"
|
||||
|
@ -11,25 +9,8 @@ macro_rules! section_end_name_template {
|
|||
}
|
||||
|
||||
pub fn write(output: &mut Output, overlay_desc: &OverlayDesc) -> Result<(), Error> {
|
||||
fn create_heap_base(overlay_desc: &OverlayDesc) -> String {
|
||||
let (first_entry, additional_slots_iter) = (&overlay_desc[0].name, overlay_desc.iter().skip(1));
|
||||
|
||||
let mut heap_start = format!(concat!("MAX({}, ", section_end_name_template!(), ")"), OVERLAY_DEFAULT_START, first_entry);
|
||||
for slot in additional_slots_iter {
|
||||
heap_start = format!(concat!("MAX(", section_end_name_template!(), ", {})"), slot.name, heap_start);
|
||||
}
|
||||
heap_start
|
||||
}
|
||||
|
||||
if overlay_desc.is_empty() {
|
||||
write_heap_base(output, OVERLAY_DEFAULT_START)?;
|
||||
}
|
||||
|
||||
else {
|
||||
write_heap_base(output, &create_heap_base(&overlay_desc))?;
|
||||
}
|
||||
|
||||
let mut slot_start_adr = format!(section_end_name_template!(), "bss");
|
||||
let has_overlays = !overlay_desc.is_empty();
|
||||
let mut slot_start_adr = format!(section_end_name_template!(), "engine_bss");
|
||||
|
||||
writeln!(output, "")?;
|
||||
writeln!(output, "SECTIONS {{")?;
|
||||
|
@ -38,22 +19,25 @@ pub fn write(output: &mut Output, overlay_desc: &OverlayDesc) -> Result<(), Erro
|
|||
writeln!(output, "\t/*{}*/", slot.name)?;
|
||||
writeln!(output, "\tOVERLAY {} : NOCROSSREFS SUBALIGN(4) {{", slot_start_adr)?;
|
||||
write_section(output, &slot.sections, false)?;
|
||||
writeln!(output, "\t}}")?;
|
||||
writeln!(output, "\t}} > ram")?;
|
||||
writeln!(output, "\t. = ALIGN(4);")?;
|
||||
writeln!(output, concat!("\t", section_end_name_template!(), " = .;"), slot.name)?;
|
||||
writeln!(output, "")?;
|
||||
|
||||
slot_start_adr = format!(section_end_name_template!(), slot.name);
|
||||
}
|
||||
|
||||
if has_overlays {
|
||||
writeln!(output, "\t__persistent_overlay_end = .;")?;
|
||||
}
|
||||
|
||||
else {
|
||||
writeln!(output, "\t__persistent_overlay_end =__engine_bss_end;")?;
|
||||
}
|
||||
writeln!(output, "}}")?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
fn write_heap_base(output: &mut Output, heap_base: &str) -> Result<(), Error> {
|
||||
format_if_error!(writeln!(output, "__heap_base = {};", heap_base), "Writing default LD Script failed with: {error_text}")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_section(output: &mut Output, sections: &Vec<OverlaySection>, add_end_name: bool) -> Result<(), Error> {
|
||||
for section in sections {
|
||||
writeln!(output, "\t\t.{} {{", section.name)?;
|
||||
|
|
Loading…
Reference in New Issue