Skip to content

Commit

Permalink
Replaced linkfile and updated Makefile to pack elf
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmicScale committed Jul 19, 2024
1 parent 5a46e07 commit 604192b
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 15 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
EE_BIN = PS1VModeNeg.elf
EE_BIN_PACKED = PS1VModeNegPacked.elf
EE_OBJS = main.o cnf_lite.o

EE_INCS := -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I.
Expand All @@ -10,10 +11,14 @@ EE_COMPACT_EXECUTABLE ?= 1

EE_LINKFILE ?= linkfile

all: $(EE_BIN)
all: $(EE_BIN_PACKED)

$(EE_BIN_PACKED): $(EE_BIN)
echo "Compressing..."
ps2-packer $< $@

clean:
rm -f $(EE_OBJS) $(EE_BIN)
rm -f $(EE_OBJS) $(EE_BIN) $(EE_BIN_PACKED)

include $(PS2SDK)/Defs.make
include $(PS2SDK)/samples/Makefile.eeglobal
77 changes: 64 additions & 13 deletions linkfile
Original file line number Diff line number Diff line change
@@ -1,70 +1,121 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
#
# Linkfile script for ee-ld
*/

ENTRY(__start);

MEMORY {
bios : ORIGIN = 0x00000000, LENGTH = 528K /* 0x00000000 - 0x00084000: BIOS memory */
bram : ORIGIN = 0x00084000, LENGTH = 496K /* 0x00084000 - 0x00100000: BIOS unused memory */
bios : ORIGIN = 0x00000000, LENGTH = 592K /* 0x00000000 - 0x00094000: BIOS memory & patched area */
bram : ORIGIN = 0x00094000, LENGTH = 432K /* 0x00094000 - 0x00100000: BIOS unused memory */
gram : ORIGIN = 0x00100000, LENGTH = 31M /* 0x00100000 - 0x02000000: GAME memory */

high : ORIGIN = 0x01ee8000, LENGTH = 1120K /* 0x01ee8000 - 0x02000000: */
}

REGION_ALIAS("MAIN_REGION", bram);

END_MAIN_REGION = ORIGIN(MAIN_REGION) + LENGTH(MAIN_REGION);

PHDRS {
text PT_LOAD;
}

SECTIONS {
.text : {
_ftext = . ;
*(.text)
*(.text.*)
*(.gnu.linkonce.t*)
KEEP(*(.init))
KEEP(*(.fini))
QUAD(0)
} >MAIN_REGION :text

.reginfo : { *(.reginfo) } >MAIN_REGION
PROVIDE(_etext = .);
PROVIDE(etext = .);

/* Global/static constructors and deconstructors. */
.ctors ALIGN(16): {
KEEP(*crtbegin*.o(.ctors))
KEEP(*(EXCLUDE_FILE(*crtend*.o) .ctors))
KEEP(*(SORT(.ctors.*)))
KEEP(*(.ctors))
} >MAIN_REGION

.dtors ALIGN(16): {
KEEP(*crtbegin*.o(.dtors))
KEEP(*(EXCLUDE_FILE(*crtend*.o) .dtors))
KEEP(*(SORT(.dtors.*)))
KEEP(*(.dtors))
} >MAIN_REGION

.rodata ALIGN(128): {
*(.rodata)
} >MAIN_REGION
.reginfo : { *(.reginfo) } >MAIN_REGION

.data ALIGN(128): {
_fdata = . ;
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
SORT(CONSTRUCTORS)
} >MAIN_REGION

/* Static data. */
.rodata ALIGN(128): {
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r*)
} >MAIN_REGION

.rdata ALIGN(128): { *(.rdata) } >MAIN_REGION
.gcc_except_table ALIGN(128): { *(.gcc_except_table) } >MAIN_REGION

_gp = ALIGN(128) + 0x7ff0;
.lit4 ALIGN(128): { *(.lit4) } >MAIN_REGION
.lit8 ALIGN(128): { *(.lit8) } >MAIN_REGION

.sdata ALIGN(128): {
*(.sdata)
*(.sdata.*)
*(.gnu.linkonce.s*)
} >MAIN_REGION

_edata = .;
PROVIDE(edata = .);

/* Uninitialized data. */
.sbss ALIGN(128) : {
_fbss = . ;
*(.sbss)
*(.sbss.*)
*(.gnu.linkonce.sb*)
*(.scommon)
} >MAIN_REGION

.bss ALIGN(128) : {
*(.bss)
*(.bss.*)
*(.gnu.linkonce.b*)
*(COMMON)
} >MAIN_REGION
_end_bss = .;

/* Symbols needed by crt0.s. */
PROVIDE(_end = .);
PROVIDE(_heap_size = -1);
_end = . ;
PROVIDE(end = .);

PROVIDE(_stack = .);
PROVIDE(_stack_size = ORIGIN(MAIN_REGION) + LENGTH(MAIN_REGION) - _stack);
}
.spad 0x70000000: {
*(.spad)
} >MAIN_REGION

/* Symbols needed by crt0.c. */
/* We set a fixed stack size and the pointer for the stack, letting the remaining memory be the heap. */
PROVIDE(_stack_size = 32 * 1024);
PROVIDE(_stack = END_MAIN_REGION - _stack_size);
PROVIDE(_heap_size = -1);
}

0 comments on commit 604192b

Please sign in to comment.