diff --git a/build-and-install.sh b/build-and-install.sh index c74617ce..48e13a32 100755 --- a/build-and-install.sh +++ b/build-and-install.sh @@ -21,11 +21,12 @@ make -j $(getconf _NPROCESSORS_ONLN) ## Install pspsdk make install -## gcc needs to include libcglue libpthreadglue libpsputility libpsprtc libpspnet_inet libpspnet_resolver libpspsdk libpspmodinfo libpspuser libpspkernel +## gcc needs to include libcglue libpthreadglue libpspprof libpsputility libpsprtc libpspnet_inet libpspnet_resolver libpspsdk libpspmodinfo libpspuser libpspkernel ## from pspsdk to be able to build executables, because they are part of the standard libraries cd "$PSPDEV/psp/lib" ln -sf "../sdk/lib/libcglue.a" "libcglue.a" || { exit 1; } ln -sf "../sdk/lib/libpthreadglue.a" "libpthreadglue.a" || { exit 1; } +ln -sf "../sdk/lib/libpspprof.a" "libpspprof.a" || { exit 1; } ln -sf "../sdk/lib/libpsputility.a" "libpsputility.a" || { exit 1; } ln -sf "../sdk/lib/libpsprtc.a" "libpsprtc.a" || { exit 1; } ln -sf "../sdk/lib/libpspnet_inet.a" "libpspnet_inet.a" || { exit 1; } diff --git a/src/libcglue/Makefile.am b/src/libcglue/Makefile.am index 8b8df2d7..4f3c59a9 100755 --- a/src/libcglue/Makefile.am +++ b/src/libcglue/Makefile.am @@ -32,7 +32,14 @@ GLUE_OBJS = __dummy_passwd.o __psp_heap_blockid.o __psp_free_heap.o _fork.o _wai openat.o renameat.o fchmodat.o fstatat.o mkdirat.o faccessat.o fchownat.o linkat.o readlinkat.o unlinkat.o \ realpath.o -INIT_OBJS = __libpthreadglue_init.o __libcglue_init.o __libcglue_deinit.o _exit.o abort.o exit.o +INIT_OBJS = \ + __libpthreadglue_init.o \ + __libcglue_init.o \ + __gprof_cleanup.o \ + __libcglue_deinit.o \ + _exit.o \ + abort.o \ + exit.o LOCK_OBJS = \ __lock___sfp_recursive_mutex.o \ diff --git a/src/libcglue/init.c b/src/libcglue/init.c index 542368b8..6dd43fbd 100644 --- a/src/libcglue/init.c +++ b/src/libcglue/init.c @@ -31,6 +31,14 @@ void __locks_deinit(); extern int sce_newlib_nocreate_thread_in_start __attribute__((weak)); +#ifdef F___gprof_cleanup +/* Note: This function is being called from _exit and it is overrided when compiling with -pg */ +__attribute__((weak)) +void __gprof_cleanup() {} +#else +void __gprof_cleanup(); +#endif + #if defined(F___libpthreadglue_init) && !defined(PSP_WITHOUT_PTHREAD) /* Note: This function is being called from __libcglue_init. * It is a weak function because can be override by user program @@ -95,6 +103,7 @@ void __libcglue_deinit(); __attribute__((__noreturn__)) void _exit (int __status) { + __gprof_cleanup(); __libcglue_deinit(); if (&sce_newlib_nocreate_thread_in_start != NULL) { diff --git a/src/prof/Makefile.am b/src/prof/Makefile.am index 93bcc1d6..1da619a3 100644 --- a/src/prof/Makefile.am +++ b/src/prof/Makefile.am @@ -11,7 +11,7 @@ CFLAGS = @PSPSDK_CFLAGS@ -std=gnu99 -Wall -Wmissing-prototypes CCASFLAGS = $(CFLAGS) -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel libpspprofincludedir = @PSPSDK_INCLUDEDIR@ -libpspprofinclude_HEADERS = pspprof.h +libpspprofinclude_HEADERS = lib_LIBRARIES = libpspprof.a libpspprof_a_SOURCES = prof.c mcount.s diff --git a/src/prof/prof.c b/src/prof/prof.c index 7a53f69d..f4d08410 100644 --- a/src/prof/prof.c +++ b/src/prof/prof.c @@ -78,7 +78,7 @@ extern int _ftext; extern int _etext; /* forward declarations */ -void gprof_cleanup(void); +void __gprof_cleanup(void); void __mcount(unsigned int, unsigned int); static SceUInt timer_handler(SceUID uid, SceKernelSysClock *c1, SceKernelSysClock *c2, void *common); @@ -156,7 +156,7 @@ static void initialize() Called from atexit() handler; will dump out a host:gmon.out file with all collected information. */ -void gprof_cleanup() +void __gprof_cleanup() { FILE *fp; int i; diff --git a/src/prof/pspprof.h b/src/prof/pspprof.h deleted file mode 100644 index d47722ac..00000000 --- a/src/prof/pspprof.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * PSP Software Development Kit - https://github.com/pspdev - * ----------------------------------------------------------------------- - * Licensed under the BSD license, see LICENSE in PSPSDK root for details. - * - * pspprof.h - Prototypes for the profiler library - * - * Copyright (c) 2006 Urchin - * - */ -#ifndef __PSPPROF_H__ -#define __PSPPROF_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -void gprof_cleanup(); - -#ifdef __cplusplus -} -#endif - -#endif /* __PSPPROF_H__ */