Skip to content

Commit

Permalink
add: Add elf-loader2 with code mainly on EE
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Jan 29, 2025
1 parent 16cae0e commit df1a3a3
Show file tree
Hide file tree
Showing 11 changed files with 1,160 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ee/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SUBDIRS = startup erl kernel libcglue libpthreadglue libprofglue rpc debug \
packet packet2 draw libgs \
libvux font input inputx network iopreboot \
mpeg \
elf-loader elf-loader-nocolour \
elf-loader elf-loader-nocolour elf-loader2 \

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/Rules.make
Expand Down
39 changes: 39 additions & 0 deletions ee/elf-loader2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

EE_OBJS = \
elf.o \
elf_loader_compat.o \
elf_loader_reader.o \
elf_loader_stdio.o \
ldrsrc.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/ee/Rules.lib.make
include $(PS2SDKSRC)/ee/Rules.make
include $(PS2SDKSRC)/ee/Rules.release

$(PS2SDKSRC)/tools/bin2c/bin/bin2c: $(PS2SDKSRC)/tools/bin2c
$(MAKEREC) $<

src/ldrsrc/bin/ldrsrc.bin:
$(MAKEREC) src/ldrsrc

$(EE_OBJS_DIR)ldrsrc.c: src/ldrsrc/bin/ldrsrc.bin $(PS2SDKSRC)/tools/bin2c/bin/bin2c
$(PS2SDKSRC)/tools/bin2c/bin/bin2c $< $@ ldrsrc

$(EE_OBJS_DIR)ldrsrc.o: $(EE_OBJS_DIR)ldrsrc.c
$(DIR_GUARD)
$(EE_C_COMPILE) $< -c -o $@

clean::
$(MAKEREC) src/ldrsrc clean

.NOTPARALLEL:: \
$(PS2SDKSRC)/tools/bin2c/bin/bin2c \
src/ldrsrc/bin/ldrsrc.bin
57 changes: 57 additions & 0 deletions ee/elf-loader2/include/elf-loader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# (c) 2020 Francisco Javier Trujillo Mata <[email protected]>
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/

/**
* @file
* ELF Loader functions.
*/

#ifndef __ELFLOADER_H__
#define __ELFLOADER_H__

#ifdef __cplusplus
extern "C" {
#endif

// Before call this method be sure that you have previously called sbv_patch_disable_prefix_check();
extern int LoadELFFromFile(const char *filename, int argc, char *argv[]);

/** Modify argv[0] when partition info should be kept
*
* @param filename path to the file itself
* @param partition block device + partition name
* @param argc Number of arguments.
* @param argv Pointer to array of arguments.
* @returns positive on success, zero value on failure
*
* You should prepare filename and partition before parsing in function
*
* filename should be changed to <fs_type>:/path_to_file_without_mountpoint
* for example `pfs3:/TEST.ELF` (where `pfs3` is mountpoint name) will become
* `pfs:/TEST.ELF` (where `pfs` - filesystem type)
*
* partition should be in form <block_device><partition_name>:
* for example `hdd0:__common:`
* block_device - can be `hdd0:`, `hdd1:` , `dvr_hdd0:`
* <partition_name> - name of APA partition on particular block device
* dont forget about leading ":"
*
* It is not necessary that filename should be on that partition
* filename - mass:/TEST.ELF
* partition - pfs:/__common
* will be valid usage
*/
extern int LoadELFFromFileWithPartition(const char *filename, const char *partition, int argc, char *argv[]);

#ifdef __cplusplus
}
#endif

#endif /* __ELFLOADER_H__ */
Loading

0 comments on commit df1a3a3

Please sign in to comment.