aboutsummaryrefslogtreecommitdiff
path: root/tools/util/elf2x.c
diff options
context:
space:
mode:
authorJohn Wilbert M. Villamor <lameguy64@gmail.com>2021-02-18 13:31:17 +0800
committerJohn Wilbert M. Villamor <lameguy64@gmail.com>2021-02-18 13:31:17 +0800
commit63419d9cc07c56234d0f61a80f32105b192aec8e (patch)
tree827cf4d134cf3b4618d0167cc912f3efd47c3aac /tools/util/elf2x.c
parent1625072293c40ba3cb819f8f48aeb4b64e93b133 (diff)
downloadpsn00bsdk-63419d9cc07c56234d0f61a80f32105b192aec8e.tar.gz
Lots of makefile corrections, improved build and toolchain instructions, added elf2cpe converter, fixed typo in plasma_tbl.h of n00bdemo example
Diffstat (limited to 'tools/util/elf2x.c')
-rw-r--r--tools/util/elf2x.c45
1 files changed, 3 insertions, 42 deletions
diff --git a/tools/util/elf2x.c b/tools/util/elf2x.c
index 612ca41..26ec9a3 100644
--- a/tools/util/elf2x.c
+++ b/tools/util/elf2x.c
@@ -4,52 +4,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "elf.h"
#define MAX_prg_entry_count 128
#define true (1)
#define false (0)
-#pragma pack(push, 1)
-
-typedef struct {
-
- unsigned int magic; // 0-3
- unsigned char word_size; // 4
- unsigned char endianness; // 5
- unsigned char elf_version; // 6
- unsigned char os_abi; // 7
- unsigned int unused[2]; // 8-15
-
- unsigned short type; // 16-17
- unsigned short instr_set; // 18-19
- unsigned int elf_version2; // 20-23
-
- unsigned int prg_entry_addr; // 24-27
- unsigned int prg_head_pos; // 28-31
- unsigned int sec_head_pos; // 32-35
- unsigned int flags; // 36-39
- unsigned short head_size; // 40-41
- unsigned short prg_entry_size; // 42-23
- unsigned short prg_entry_count; // 44-45
- unsigned short sec_entry_size; // 46-47
- unsigned short sec_entry_count; // 48-49
- unsigned short sec_names_index; // 50-51
-
-} ELF_HEADER;
-
-typedef struct {
- unsigned int seg_type;
- unsigned int p_offset;
- unsigned int p_vaddr;
- unsigned int undefined;
- unsigned int p_filesz;
- unsigned int p_memsz;
- unsigned int flags;
- unsigned int alignment;
-} PRG_HEADER;
-
-#pragma pack(pop)
-
typedef struct {
unsigned int pc0;
unsigned int gp0;
@@ -112,7 +72,7 @@ int main(int argc, char** argv) {
if( !quiet ) {
printf( "PSn00bSDK elf2x - ELF to PS-EXE Converter\n" );
- printf( "2018-2019 Meido-Tek Productions\n\n" );
+ printf( "2018-2021 Meido-Tek Productions\n\n" );
}
if( argc == 1 ) {
@@ -140,6 +100,7 @@ int main(int argc, char** argv) {
// Check header
if( head.magic != 0x464c457f ) {
printf( "File is not an ELF file.\n" );
+ fclose( fp );
return EXIT_FAILURE;
}