Skip to content

Commit df1a3a3

Browse files
committed
add: Add elf-loader2 with code mainly on EE
1 parent 16cae0e commit df1a3a3

File tree

11 files changed

+1160
-1
lines changed

11 files changed

+1160
-1
lines changed

ee/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SUBDIRS = startup erl kernel libcglue libpthreadglue libprofglue rpc debug \
1111
packet packet2 draw libgs \
1212
libvux font input inputx network iopreboot \
1313
mpeg \
14-
elf-loader elf-loader-nocolour \
14+
elf-loader elf-loader-nocolour elf-loader2 \
1515

1616
include $(PS2SDKSRC)/Defs.make
1717
include $(PS2SDKSRC)/Rules.make

ee/elf-loader2/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# _____ ___ ____ ___ ____
2+
# ____| | ____| | | |____|
3+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
4+
#-----------------------------------------------------------------------
5+
# Copyright ps2dev - http://www.ps2dev.org
6+
# Licenced under Academic Free License version 2.0
7+
# Review ps2sdk README & LICENSE files for further details.
8+
9+
EE_OBJS = \
10+
elf.o \
11+
elf_loader_compat.o \
12+
elf_loader_reader.o \
13+
elf_loader_stdio.o \
14+
ldrsrc.o
15+
16+
include $(PS2SDKSRC)/Defs.make
17+
include $(PS2SDKSRC)/ee/Rules.lib.make
18+
include $(PS2SDKSRC)/ee/Rules.make
19+
include $(PS2SDKSRC)/ee/Rules.release
20+
21+
$(PS2SDKSRC)/tools/bin2c/bin/bin2c: $(PS2SDKSRC)/tools/bin2c
22+
$(MAKEREC) $<
23+
24+
src/ldrsrc/bin/ldrsrc.bin:
25+
$(MAKEREC) src/ldrsrc
26+
27+
$(EE_OBJS_DIR)ldrsrc.c: src/ldrsrc/bin/ldrsrc.bin $(PS2SDKSRC)/tools/bin2c/bin/bin2c
28+
$(PS2SDKSRC)/tools/bin2c/bin/bin2c $< $@ ldrsrc
29+
30+
$(EE_OBJS_DIR)ldrsrc.o: $(EE_OBJS_DIR)ldrsrc.c
31+
$(DIR_GUARD)
32+
$(EE_C_COMPILE) $< -c -o $@
33+
34+
clean::
35+
$(MAKEREC) src/ldrsrc clean
36+
37+
.NOTPARALLEL:: \
38+
$(PS2SDKSRC)/tools/bin2c/bin/bin2c \
39+
src/ldrsrc/bin/ldrsrc.bin

ee/elf-loader2/include/elf-loader.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# (c) 2020 Francisco Javier Trujillo Mata <[email protected]>
7+
# Licenced under Academic Free License version 2.0
8+
# Review ps2sdk README & LICENSE files for further details.
9+
*/
10+
11+
/**
12+
* @file
13+
* ELF Loader functions.
14+
*/
15+
16+
#ifndef __ELFLOADER_H__
17+
#define __ELFLOADER_H__
18+
19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
23+
// Before call this method be sure that you have previously called sbv_patch_disable_prefix_check();
24+
extern int LoadELFFromFile(const char *filename, int argc, char *argv[]);
25+
26+
/** Modify argv[0] when partition info should be kept
27+
*
28+
* @param filename path to the file itself
29+
* @param partition block device + partition name
30+
* @param argc Number of arguments.
31+
* @param argv Pointer to array of arguments.
32+
* @returns positive on success, zero value on failure
33+
*
34+
* You should prepare filename and partition before parsing in function
35+
*
36+
* filename should be changed to <fs_type>:/path_to_file_without_mountpoint
37+
* for example `pfs3:/TEST.ELF` (where `pfs3` is mountpoint name) will become
38+
* `pfs:/TEST.ELF` (where `pfs` - filesystem type)
39+
*
40+
* partition should be in form <block_device><partition_name>:
41+
* for example `hdd0:__common:`
42+
* block_device - can be `hdd0:`, `hdd1:` , `dvr_hdd0:`
43+
* <partition_name> - name of APA partition on particular block device
44+
* dont forget about leading ":"
45+
*
46+
* It is not necessary that filename should be on that partition
47+
* filename - mass:/TEST.ELF
48+
* partition - pfs:/__common
49+
* will be valid usage
50+
*/
51+
extern int LoadELFFromFileWithPartition(const char *filename, const char *partition, int argc, char *argv[]);
52+
53+
#ifdef __cplusplus
54+
}
55+
#endif
56+
57+
#endif /* __ELFLOADER_H__ */

0 commit comments

Comments
 (0)