Allow overlapping Overlays
This commit is contained in:
parent
33ff9936fd
commit
6710fc825a
|
@ -62,7 +62,7 @@ CCFLAGS += -DJABYENGINE_$(TV_FORMAT)
|
||||||
#Linker flags
|
#Linker flags
|
||||||
LDFLAGS_release += -Os
|
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
|
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 += $(ARCHFLAGS) -Wl,--oformat=$(FORMAT)
|
LDFLAGS_all += $(ARCHFLAGS) -Wl,--oformat=$(FORMAT)
|
||||||
LDFLAGS_all += $(LDFLAGS_$(BUILD_PROFILE))
|
LDFLAGS_all += $(LDFLAGS_$(BUILD_PROFILE))
|
||||||
|
|
||||||
|
|
36
lib/psexe.ld
36
lib/psexe.ld
|
@ -34,6 +34,7 @@ TLOAD_ADDR = DEFINED(TLOAD_ADDR) ? TLOAD_ADDR : 0x80010000;
|
||||||
MEMORY {
|
MEMORY {
|
||||||
loader : ORIGIN = (TLOAD_ADDR - 0x800), LENGTH = 2048
|
loader : ORIGIN = (TLOAD_ADDR - 0x800), LENGTH = 2048
|
||||||
ram (rwx) : ORIGIN = 0x80010000, LENGTH = 2M - 0x10000
|
ram (rwx) : ORIGIN = 0x80010000, LENGTH = 2M - 0x10000
|
||||||
|
ram2 (rwx) : ORIGIN = 0x80010000, LENGTH = 2M - 0x10000
|
||||||
dcache : ORIGIN = 0x1f800000, LENGTH = 0x400
|
dcache : ORIGIN = 0x1f800000, LENGTH = 0x400
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +61,39 @@ SECTIONS {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Overlay sections created by mkoverlay*/
|
/*Overlay sections created by mkoverlay*/
|
||||||
|
SECTIONS {
|
||||||
|
.planschi __bss_end : SUBALIGN(4)
|
||||||
|
{
|
||||||
|
__planschi_start = .;
|
||||||
|
__boot_loader_start = .;
|
||||||
|
|
||||||
|
*libJabyEngine.a:*_boot.o(.text.startup._GLOBAL__*)
|
||||||
|
*_boot.o(.text.startup._GLOBAL__*)
|
||||||
|
*libJabyEngine.a:*_boot.o(.ctors)
|
||||||
|
*_boot.o(.ctors)
|
||||||
|
|
||||||
|
*libJabyEngine.a:*_boot.o(.text.*)
|
||||||
|
*_boot.o(.text.*)
|
||||||
|
*libJabyEngine.a:*_boot.o(.rodata*)
|
||||||
|
*_boot.o(.rodata*)
|
||||||
|
*libJabyEngine.a:*_boot.o(.sdata*)
|
||||||
|
*_boot.o(.sdata*)
|
||||||
|
*libJabyEngine.a:*_boot.o(.data*)
|
||||||
|
*_boot.o(.data*)
|
||||||
|
*libJabyEngine.a:*_boot.o(.sbss*)
|
||||||
|
*_boot.o(.sbss*)
|
||||||
|
*libJabyEngine.a:*_boot.o(.bss*)
|
||||||
|
*_boot.o(.bss*)
|
||||||
|
*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 = .;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SECTIONS {
|
SECTIONS {
|
||||||
.PSX_EXE_Header : {
|
.PSX_EXE_Header : {
|
||||||
|
@ -181,7 +215,7 @@ SECTIONS {
|
||||||
__data_end = .;
|
__data_end = .;
|
||||||
__fdata_end = .;
|
__fdata_end = .;
|
||||||
__bss_start = .;
|
__bss_start = .;
|
||||||
.sbss : {
|
.bss : {
|
||||||
*(.dynsbss)
|
*(.dynsbss)
|
||||||
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
||||||
*(.scommon)
|
*(.scommon)
|
||||||
|
|
|
@ -24,13 +24,7 @@ pub fn write(output: &mut Output, overlay_desc: &OverlayDesc) -> Result<(), Erro
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_slot_start_adr(slot: &OverlaySlot) -> &str {
|
fn get_slot_start_adr(slot: &OverlaySlot) -> &str {
|
||||||
if let Some(slot_adr) = &slot.start_adr {
|
slot.start_adr.as_ref()
|
||||||
slot_adr.as_ref()
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
OVERLAY_DEFAULT_START
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if overlay_desc.additional_slots.is_empty() && overlay_desc.boot_section.is_empty() {
|
if overlay_desc.additional_slots.is_empty() && overlay_desc.boot_section.is_empty() {
|
||||||
|
@ -44,7 +38,7 @@ pub fn write(output: &mut Output, overlay_desc: &OverlayDesc) -> Result<(), Erro
|
||||||
writeln!(output, "")?;
|
writeln!(output, "")?;
|
||||||
writeln!(output, "SECTIONS {{")?;
|
writeln!(output, "SECTIONS {{")?;
|
||||||
writeln!(output, "\t/DISCARD/ : {{ *(.comment*) *(.gnu.*) *(.mdebug*) *(.debug_*) *(.pdr)}}")?;
|
writeln!(output, "\t/DISCARD/ : {{ *(.comment*) *(.gnu.*) *(.mdebug*) *(.debug_*) *(.pdr)}}")?;
|
||||||
write_planschi_section(output, &overlay_desc.boot_section)?;
|
write_first_section(output, &overlay_desc.boot_section)?;
|
||||||
for slot in &overlay_desc.additional_slots {
|
for slot in &overlay_desc.additional_slots {
|
||||||
writeln!(output, "\t/*{}*/", slot.name)?;
|
writeln!(output, "\t/*{}*/", slot.name)?;
|
||||||
writeln!(output, "\tOVERLAY {} : NOCROSSREFS SUBALIGN(4) {{", get_slot_start_adr(slot))?;
|
writeln!(output, "\tOVERLAY {} : NOCROSSREFS SUBALIGN(4) {{", get_slot_start_adr(slot))?;
|
||||||
|
@ -63,39 +57,8 @@ fn write_heap_base(output: &mut Output, heap_base: &str) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_planschi_section(output: &mut Output, boot_overlay: &BootOverlaySection) -> Result<(), Error> {
|
fn write_first_section(output: &mut Output, boot_overlay: &BootOverlaySection) -> Result<(), Error> {
|
||||||
writeln!(output, "\tOVERLAY __bss_end : NOCROSSREFS SUBALIGN(4) {{")?;
|
writeln!(output, "\tOVERLAY __bss_end : NOCROSSREFS SUBALIGN(4) {{")?;
|
||||||
writeln!(output, "\t\t.planschi {{")?;
|
|
||||||
writeln!(output, "\t\t\t__planschi_start = .;")?;
|
|
||||||
writeln!(output, "\t\t\t__boot_loader_start = .;")?;
|
|
||||||
writeln!(output, "")?;
|
|
||||||
writeln!(output, "\t\t\t*libJabyEngine.a:*_boot.o(.text.startup._GLOBAL__*)")?;
|
|
||||||
writeln!(output, "\t\t\t*_boot.o(.text.startup._GLOBAL__*)")?;
|
|
||||||
writeln!(output, "\t\t\t*libJabyEngine.a:*_boot.o(.ctors)")?;
|
|
||||||
writeln!(output, "\t\t\t*_boot.o(.ctors)")?;
|
|
||||||
writeln!(output, "")?;
|
|
||||||
writeln!(output, "\t\t\t*libJabyEngine.a:*_boot.o(.text.*)")?;
|
|
||||||
writeln!(output, "\t\t\t*_boot.o(.text.*)")?;
|
|
||||||
writeln!(output, "\t\t\t*libJabyEngine.a:*_boot.o(.rodata*)")?;
|
|
||||||
writeln!(output, "\t\t\t*_boot.o(.rodata*)")?;
|
|
||||||
writeln!(output, "\t\t\t*libJabyEngine.a:*_boot.o(.sdata*)")?;
|
|
||||||
writeln!(output, "\t\t\t*_boot.o(.sdata*)")?;
|
|
||||||
writeln!(output, "\t\t\t*libJabyEngine.a:*_boot.o(.data*)")?;
|
|
||||||
writeln!(output, "\t\t\t*_boot.o(.data*)")?;
|
|
||||||
writeln!(output, "\t\t\t*libJabyEngine.a:*_boot.o(.sbss*)")?;
|
|
||||||
writeln!(output, "\t\t\t*_boot.o(.sbss*)")?;
|
|
||||||
writeln!(output, "\t\t\t*libJabyEngine.a:*_boot.o(.bss*)")?;
|
|
||||||
writeln!(output, "\t\t\t*_boot.o(.bss*)")?;
|
|
||||||
writeln!(output, "\t\t\t*libJabyEngine.a:*_boot.o(*)")?;
|
|
||||||
writeln!(output, "\t\t\t*_boot.o(*)")?;
|
|
||||||
writeln!(output, "")?;
|
|
||||||
writeln!(output, "\t\t\t. = ALIGN(4);")?;
|
|
||||||
writeln!(output, "\t\t\t__boot_loader_end = .;")?;
|
|
||||||
writeln!(output, "\t\t\t/*Only needed for the PSX BIOS to load the entire game*/")?;
|
|
||||||
writeln!(output, "\t\t\t. = ALIGN(2048);")?;
|
|
||||||
writeln!(output, "\t\t\t__planschi_end = .;")?;
|
|
||||||
writeln!(output, "\t\t}}")?;
|
|
||||||
writeln!(output, "")?;
|
|
||||||
writeln!(output, "\t\t/*{}*/", boot_overlay.name)?;
|
writeln!(output, "\t\t/*{}*/", boot_overlay.name)?;
|
||||||
write_section(output, &boot_overlay.sections, true)?;
|
write_section(output, &boot_overlay.sections, true)?;
|
||||||
writeln!(output, "\t}}")?;
|
writeln!(output, "\t}}")?;
|
||||||
|
|
|
@ -10,24 +10,18 @@ pub fn read_config(input: Input) -> Result<OverlayDesc, Error> {
|
||||||
if let Some(objects) = json_reader.as_object() {
|
if let Some(objects) = json_reader.as_object() {
|
||||||
for object in objects {
|
for object in objects {
|
||||||
let mut slot = read_as_slot(object)?;
|
let mut slot = read_as_slot(object)?;
|
||||||
if slot.start_adr.is_none() {
|
if overlay_desc.boot_section.is_empty() {
|
||||||
if overlay_desc.boot_section.is_empty() {
|
overlay_desc.boot_section = BootOverlaySection::new(slot.name, slot.sections);
|
||||||
overlay_desc.boot_section = BootOverlaySection::new(slot.name, slot.sections);
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
if let Some(prev_slot) = overlay_desc.additional_slots.last() {
|
|
||||||
slot.set_start_adr_as_end_of(prev_slot.name.as_ref());
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
slot.set_start_adr_as_end_of("planschi");
|
|
||||||
}
|
|
||||||
overlay_desc.additional_slots.push(slot);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
if let Some(prev_slot) = overlay_desc.additional_slots.last() {
|
||||||
|
slot.set_start_adr_as_end_of(prev_slot.name.as_ref());
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
slot.set_start_adr_as_end_of("bss");
|
||||||
|
}
|
||||||
overlay_desc.additional_slots.push(slot);
|
overlay_desc.additional_slots.push(slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +36,7 @@ pub fn read_config(input: Input) -> Result<OverlayDesc, Error> {
|
||||||
|
|
||||||
fn read_as_slot(json_value: (&String, &serde_json::Value)) -> Result<OverlaySlot, Error> {
|
fn read_as_slot(json_value: (&String, &serde_json::Value)) -> Result<OverlaySlot, Error> {
|
||||||
let (slot_name, json_value) = json_value;
|
let (slot_name, json_value) = json_value;
|
||||||
let mut slot = OverlaySlot::new(slot_name.clone(), None);
|
let mut slot = OverlaySlot::new(slot_name.clone(), "bss");
|
||||||
|
|
||||||
if let Some(json_value) = json_value.as_object() {
|
if let Some(json_value) = json_value.as_object() {
|
||||||
for (name, json_value) in json_value {
|
for (name, json_value) in json_value {
|
||||||
|
|
|
@ -49,26 +49,17 @@ impl OverlaySection {
|
||||||
|
|
||||||
pub struct OverlaySlot {
|
pub struct OverlaySlot {
|
||||||
pub(super) name: String,
|
pub(super) name: String,
|
||||||
pub(super) start_adr: Option<String>,
|
pub(super) start_adr: String,
|
||||||
pub(super) sections: Vec<OverlaySection>
|
pub(super) sections: Vec<OverlaySection>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OverlaySlot {
|
impl OverlaySlot {
|
||||||
pub fn new(name: String, start_adr: Option<&str>) -> OverlaySlot {
|
pub fn new(name: String, start_adr: &str) -> OverlaySlot {
|
||||||
let start_adr = {
|
OverlaySlot{name, start_adr: String::from(start_adr), sections: Vec::new()}
|
||||||
if let Some(str) = start_adr {
|
|
||||||
Some(str.to_owned())
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
};
|
|
||||||
OverlaySlot{name, start_adr, sections: Vec::new()}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_start_adr_as_end_of(&mut self, end: &str) {
|
pub fn set_start_adr_as_end_of(&mut self, end: &str) {
|
||||||
self.start_adr = Some(format!("__{}_end", end));
|
self.start_adr = format!("__{}_end", end);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_section(&mut self, section: OverlaySection) {
|
pub fn add_section(&mut self, section: OverlaySection) {
|
||||||
|
|
Loading…
Reference in New Issue