Skip to content

Commit

Permalink
A dummy example to show how to make binary smaller
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtrujy committed Nov 29, 2024
1 parent 51cbe52 commit feed6de
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/samples/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ SAMPLES = \
kernel/regenum \
kernel/systimer \
kernel/sysevent \
libcglue/light_elf \
mp3 \
ms/callback \
nand/dumpipl \
Expand Down
1 change: 1 addition & 0 deletions src/samples/Makefile.samples
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ SAMPLES = \
kernel/regenum \
kernel/systimer \
kernel/sysevent \
libcglue/light_elf \
mp3 \
ms/callback \
nand/dumpipl \
Expand Down
16 changes: 16 additions & 0 deletions src/samples/libcglue/light_elf/Makefile.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
TARGET = light_size
OBJS = main.o

INCDIR =
CFLAGS = -Os -Wall -fdata-sections -ffunction-sections
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS = -s

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Light Hello World

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
43 changes: 43 additions & 0 deletions src/samples/libcglue/light_elf/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* PSP Software Development Kit - https://github.com/pspdev
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
*
* Sample program to demonstrate a minimalistic Hello World program.
* The main scope here is to show how we can disable newlib features if we don't need them.
*/

#include <stdio.h>

// Specific psp headers
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspkernel.h>
#include <pspmoduleinfo.h>
#include <errno.h>

// We won't fully disable newlib as we are using printf
// However we can disable timezone, pthreads, pipe and socket support
PSP_DISABLE_NEWLIB_PIPE_SUPPORT()
PSP_DISABLE_NEWLIB_SOCKET_SUPPORT()
PSP_DISABLE_NEWLIB_TIMEZONE_SUPPORT()
PSP_DISABLE_NEWLIB_CWD_SUPPORT()
PSP_DISABLE_AUTOSTART_PTHREAD()

// configure PSP stuff
#define VERS 1
#define REVS 0

PSP_MODULE_INFO("Light Hello World", PSP_MODULE_USER, VERS, REVS);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);

int main(int argc, char** argv)
{
while(1) {
printf("Hello World!\n");
}

return 0;
}

0 comments on commit feed6de

Please sign in to comment.