mirror of
https://github.com/joel16/uofw.git
synced 2024-11-23 03:29:43 +00:00
Finished the build system, with the import side: now our modules will be easily able to import functions and variables. Modified pspimport.s and added a modified version of psp-fixup-imports to support variables.
This commit is contained in:
parent
4aa8a3def6
commit
89b7f942a1
2
COPYING
2
COPYING
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2011 The uOFW team
|
||||
Copyright (c) 2011, 2012 The uOFW team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
2
Doxyfile
2
Doxyfile
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2011 The uOFW team
|
||||
# Copyright (C) 2011, 2012 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
# Doxyfile 1.7.4
|
||||
|
85
include/pspimport.s
Normal file
85
include/pspimport.s
Normal file
@ -0,0 +1,85 @@
|
||||
|
||||
.macro IMPORT_START module, flags_ver
|
||||
|
||||
.set push
|
||||
.section .rodata.sceResident, "a"
|
||||
.word 0
|
||||
__stub_modulestr_\module:
|
||||
.asciz "\module"
|
||||
.align 2
|
||||
|
||||
.section .lib.stub, "a", @progbits
|
||||
.global __stub_module_\module
|
||||
__stub_module_\module:
|
||||
.word __stub_modulestr_\module
|
||||
.word \flags_ver
|
||||
.word 0x5
|
||||
.word __executable_start
|
||||
.word __executable_start
|
||||
.word __executable_start
|
||||
|
||||
.set pop
|
||||
.endm
|
||||
|
||||
.macro IMPORT_FUNC module, funcid, funcname
|
||||
|
||||
.set push
|
||||
.set noreorder
|
||||
|
||||
.extern __stub_module_\module
|
||||
.section .sceStub.text, "ax", @progbits
|
||||
.globl \funcname
|
||||
.type \funcname, @function
|
||||
.ent \funcname, 0
|
||||
\funcname:
|
||||
.word __stub_module_\module
|
||||
.word \funcid
|
||||
.end \funcname
|
||||
.size \funcname, .-\funcname
|
||||
|
||||
.section .rodata.sceNid, "a"
|
||||
.word \funcid
|
||||
|
||||
.set pop
|
||||
.endm
|
||||
|
||||
.macro IMPORT_FUNC_WITH_ALIAS module, funcid, funcname, alias
|
||||
|
||||
.set push
|
||||
.set noreorder
|
||||
|
||||
.extern __stub_module_\module
|
||||
.section .sceStub.text, "ax", @progbits
|
||||
.globl \alias
|
||||
.type \alias, @function
|
||||
\alias:
|
||||
.globl \funcname
|
||||
.type \funcname, @function
|
||||
.ent \funcname, 0
|
||||
\funcname:
|
||||
.word __stub_module_\module
|
||||
.word \funcid
|
||||
.end \funcname
|
||||
.size \funcname, .-\funcname
|
||||
|
||||
.section .rodata.sceNid, "a"
|
||||
.word \funcid
|
||||
|
||||
.set pop
|
||||
.endm
|
||||
|
||||
.macro IMPORT_VAR module, varid, varname
|
||||
|
||||
.set push
|
||||
.set noreorder
|
||||
|
||||
.extern __stub_module_\module
|
||||
.section .rodata.sceVstub, "a"
|
||||
.globl \varname
|
||||
\varname:
|
||||
.word __stub_module_\module
|
||||
.word \varid
|
||||
|
||||
.set pop
|
||||
.endm
|
||||
|
@ -1,10 +1,7 @@
|
||||
# Copyright (C) 2011, 2012 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
CC = psp-gcc
|
||||
CXX = psp-g++
|
||||
AS = psp-gcc
|
||||
FIXUP = psp-fixup-imports
|
||||
include ../../lib/common.mak
|
||||
|
||||
CFLAGS := -I../../include -O1 -fno-toplevel-reorder -G0 -Wall -Wextra -Werror -nostdlib
|
||||
LDFLAGS := -specs=../../lib/prxspecs -Wl,-q,-T../../lib/linkfile.prx
|
||||
@ -16,16 +13,21 @@ else
|
||||
$(error You have to define PRX_EXPORTS in your Makefile)
|
||||
endif
|
||||
|
||||
MODULE_STUBS=$(foreach mod,$(MODULES), $($(mod)_STUBS))
|
||||
|
||||
all: $(TARGET).prx
|
||||
|
||||
$(TARGET).elf: $(OBJS) $(EXPORT_OBJ)
|
||||
$(LINK.c) $^ $(LIBS) -o $@
|
||||
-$(FIXUP) $@
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
|
||||
../../utils/fixup-imports/psp-fixup-imports $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $^ -o $@ $(CFLAGS)
|
||||
|
||||
%.prx: %.elf
|
||||
../../utils/kprxgen/psp-kprxgen $< $@
|
||||
|
||||
%.c: %.exp
|
||||
$(PRX_EXPORTS:.exp=.c): $(PRX_EXPORTS)
|
||||
../../utils/build-exports/psp-build-exports -b $< > $@
|
||||
|
||||
clean:
|
||||
@ -33,3 +35,14 @@ clean:
|
||||
|
||||
rebuild: clean all
|
||||
|
||||
Makefile.exp: $(PRX_EXPORTS)
|
||||
cat ../../lib/build_stubs.mak > Makefile.exp
|
||||
../../utils/build-exports/psp-build-exports -k $< >> Makefile.exp
|
||||
|
||||
exp: Makefile.exp
|
||||
make -f Makefile.exp
|
||||
|
||||
exp-clean:
|
||||
make -f Makefile.exp clean
|
||||
-rm -f Makefile.exp
|
||||
|
||||
|
7
lib/build_stubs.mak
Normal file
7
lib/build_stubs.mak
Normal file
@ -0,0 +1,7 @@
|
||||
# Copyright (C) 2011, 2012 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
include ../../lib/common.mak
|
||||
|
||||
CFLAGS=-O2 -G0 -Wall -I../../include
|
||||
|
10
lib/common.mak
Normal file
10
lib/common.mak
Normal file
@ -0,0 +1,10 @@
|
||||
# Copyright (C) 2011, 2012 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
CC = psp-gcc
|
||||
CXX = psp-g++
|
||||
AS = psp-gcc
|
||||
FIXUP = psp-fixup-imports
|
||||
AR = psp-ar
|
||||
RANLIB = psp-ranlib
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2011 The uOFW team
|
||||
# Copyright (C) 2011, 2012 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
CPP=c++
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2011 The uOFW team
|
||||
/* Copyright (C) 2011, 2012 The uOFW team
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
# Copyright (C) 2011 The uOFW team
|
||||
# Copyright (C) 2011, 2012 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
CPP=gcc
|
||||
CFLAGS=-Wall -Wextra -Werror
|
||||
LDFLAGS=
|
||||
TARGET=psp-build-exports
|
||||
OBJECTS=sha1.o psp-build-exports.o
|
||||
OBJECTS=../common/sha1.o psp-build-exports.o
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2011 The uOFW team
|
||||
/* Copyright (C) 2011, 2012 The uOFW team
|
||||
See the file COPYING for copying permission.
|
||||
|
||||
Based on the original file from PSPSDK, written by tyranid; many thanks to him!
|
||||
@ -12,7 +12,7 @@
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "sha1.h"
|
||||
#include "../common/sha1.h"
|
||||
|
||||
#define MAX_LIB_NAME 27
|
||||
#define MAX_LIB_FUNCS 65535
|
||||
@ -472,6 +472,7 @@ void build_stubs_output_lib_new(struct psp_lib *pLib)
|
||||
fprintf(fp, "\t.set noreorder\n\n");
|
||||
fprintf(fp, "#include \"pspimport.s\"\n\n");
|
||||
|
||||
/*
|
||||
fprintf(fp, "// Build files\n");
|
||||
fprintf(fp, "// %s_0000.o ", pLib->name);
|
||||
pExp = pLib->pFuncHead;
|
||||
@ -481,9 +482,39 @@ void build_stubs_output_lib_new(struct psp_lib *pLib)
|
||||
fprintf(fp, "%s_%04d.o ", pLib->name, i++);
|
||||
pExp = pExp->pNext;
|
||||
}
|
||||
pExp = pLib->pVarHead;
|
||||
while(pExp != NULL)
|
||||
{
|
||||
fprintf(fp, "%s_%04d.o ", pLib->name, i++);
|
||||
pExp = pExp->pNext;
|
||||
}
|
||||
fprintf(fp, "\n\n");
|
||||
*/
|
||||
|
||||
fprintf(fp, "#ifdef F_%s_0000\n", pLib->name);
|
||||
int count = 1;
|
||||
pExp = pLib->pFuncHead;
|
||||
while(pExp != NULL)
|
||||
{
|
||||
count++;
|
||||
pExp = pExp->pNext;
|
||||
}
|
||||
pExp = pLib->pVarHead;
|
||||
while(pExp != NULL)
|
||||
{
|
||||
count++;
|
||||
pExp = pExp->pNext;
|
||||
}
|
||||
|
||||
printf("%s_OBJS = ", pLib->name);
|
||||
for (i = 0; i < count; i++)
|
||||
printf("%s_%04d.o ", pLib->name, i);
|
||||
printf("\n\n$(%s_OBJS): %s.S\n", pLib->name, pLib->name);
|
||||
printf("\t$(CC) -D$* $(CFLAGS) -c $< -o $@\n\n");
|
||||
printf("lib%s.a: $(%s_OBJS)\n", pLib->name, pLib->name);
|
||||
printf("\t$(AR) cru $@ $^\n");
|
||||
printf("\t$(RANLIB) $@\n");
|
||||
|
||||
fprintf(fp, "#ifdef %s_0000\n", pLib->name);
|
||||
fprintf(fp, "\tIMPORT_START \"%s\",0x%08X\n", pLib->name, ((pLib->attr | 0x8) << 16) | pLib->ver);
|
||||
fprintf(fp, "#endif\n");
|
||||
|
||||
@ -492,7 +523,7 @@ void build_stubs_output_lib_new(struct psp_lib *pLib)
|
||||
while(pExp != NULL)
|
||||
{
|
||||
const char *alias;
|
||||
fprintf(fp, "#ifdef F_%s_%04d\n", pLib->name, i++);
|
||||
fprintf(fp, "#ifdef %s_%04d\n", pLib->name, i++);
|
||||
|
||||
alias = find_alias(pLib->pAliasHead, pExp->name);
|
||||
if(alias)
|
||||
@ -508,6 +539,15 @@ void build_stubs_output_lib_new(struct psp_lib *pLib)
|
||||
pExp = pExp->pNext;
|
||||
}
|
||||
|
||||
pExp = pLib->pVarHead;
|
||||
while(pExp != NULL)
|
||||
{
|
||||
fprintf(fp, "#ifdef %s_%04d\n", pLib->name, i++);
|
||||
fprintf(fp, "\tIMPORT_VAR \"%s\",0x%08X,%s\n", pLib->name, pExp->nid, pExp->name);
|
||||
fprintf(fp, "#endif\n");
|
||||
pExp = pExp->pNext;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
@ -521,7 +561,19 @@ void build_stubs(void)
|
||||
struct psp_lib *pLib;
|
||||
|
||||
pLib = g_libhead;
|
||||
if(g_outputmode != PSP_BUILD_STUBS)
|
||||
{
|
||||
printf("all: ");
|
||||
while (pLib != NULL)
|
||||
{
|
||||
if(strcmp(pLib->name, SYSTEM_LIB_NAME))
|
||||
printf("lib%s.a ", pLib->name);
|
||||
pLib = pLib->pNext;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
pLib = g_libhead;
|
||||
while(pLib != NULL)
|
||||
{
|
||||
if(strcmp(pLib->name, SYSTEM_LIB_NAME))
|
||||
@ -538,6 +590,19 @@ void build_stubs(void)
|
||||
|
||||
pLib = pLib->pNext;
|
||||
}
|
||||
|
||||
pLib = g_libhead;
|
||||
if(g_outputmode != PSP_BUILD_STUBS)
|
||||
{
|
||||
printf("clean:\n\t-rm -f ");
|
||||
while (pLib != NULL)
|
||||
{
|
||||
if(strcmp(pLib->name, SYSTEM_LIB_NAME))
|
||||
printf("$(%s_OBJS) ", pLib->name);
|
||||
pLib = pLib->pNext;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
int validate_number(const char *str, unsigned int *num)
|
||||
|
@ -57,6 +57,7 @@ struct PspModuleImport
|
||||
u16 func_count;
|
||||
u32 nids;
|
||||
u32 funcs;
|
||||
u32 vars;
|
||||
};
|
||||
|
||||
/* Structure to hold the module info */
|
27
utils/fixup-imports/Makefile
Normal file
27
utils/fixup-imports/Makefile
Normal file
@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2011, 2012 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
CPP=gcc
|
||||
CFLAGS=-Wall -Wextra -Werror
|
||||
LDFLAGS=
|
||||
TARGET=psp-fixup-imports
|
||||
OBJECTS=../common/sha1.o psp-fixup-imports.o
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
@echo "Creating binary $(TARGET)"
|
||||
@$(CPP) $(OBJECTS) -o $@ $(LDFLAGS)
|
||||
|
||||
%.o: %.cpp
|
||||
@echo "Compiling $^"
|
||||
$(CPP) $(CFLAGS) -c $^ -o $@
|
||||
|
||||
clean:
|
||||
@echo "Removing all the .o files"
|
||||
@$(RM) $(OBJECTS)
|
||||
|
||||
mrproper: clean
|
||||
@echo "Removing binary"
|
||||
@$(RM) $(TARGET)
|
||||
|
1042
utils/fixup-imports/psp-fixup-imports.c
Normal file
1042
utils/fixup-imports/psp-fixup-imports.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2011 The uOFW team
|
||||
# Copyright (C) 2011, 2012 The uOFW team
|
||||
# See the file COPYING for copying permission.
|
||||
|
||||
CPP=gcc
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2011 The uOFW team
|
||||
/* Copyright (C) 2011, 2012 The uOFW team
|
||||
See the file COPYING for copying permission.
|
||||
|
||||
Based on the original file from PSPSDK, written by tyranid; many thanks to him!
|
||||
@ -16,9 +16,9 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
#include "elftypes.h"
|
||||
#include "prxtypes.h"
|
||||
#include "../common/types.h"
|
||||
#include "../common/elftypes.h"
|
||||
#include "../common/prxtypes.h"
|
||||
|
||||
/* Arrangement of ELF file after stripping
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user