Hi,
Since .elf contents are loaded in memory on Nintendo DS and that we face big memory limitations (specially when including graphics & sound in the .elf file), I propose a modification of the Makefile template (if there's one) or at least suggest some fine option which allow to reduce code size:
compiler options: add -ffunction-sections -fdata-sections => put each data & function in a separate section
link option: add -Wl,--gc-sections => garbage collect unreferenced sections => removes all your unused code, but also compiler generated code & data which is finally unused. It means that even if all of your routines are used, it still saves ROM.
On my project, I could reduce the .elf file from 800k to 700k only with that (that's also some options we are using at work for an embedded application to save a lot of ROM).
bye
decreasing executable size with gcc options
Re: decreasing executable size with gcc options
I know this topic is a bit old, but, if anyone is curious..
I'm assuming you're using devkitARM.
Open devkitARM/base_rules, and add:
Then in devkitARM/ds_rules, add:
To the very bottom of the file in the "%.elf:" section..
At the beginning of each of those 2 lines there is a <TAB>.
I'm assuming you're using devkitARM.
Open devkitARM/base_rules, and add:
Code: Select all
export STRIP := $(PREFIX)strip
Code: Select all
@echo stripping $(notdir $@)
@$(STRIP) -s $@
At the beginning of each of those 2 lines there is a <TAB>.
Re: decreasing executable size with gcc options
Yes, -s is good too, since you don't need debug symbols on the DS
Also use -Os instead of -O2. Saves some more bytes.
to sum it up, compile -ffunction-sections, -fdata-sections, -Os, link with --gc-sections and -s
Also use -Os instead of -O2. Saves some more bytes.
to sum it up, compile -ffunction-sections, -fdata-sections, -Os, link with --gc-sections and -s
Re: decreasing executable size with gcc options
To my knowledge, objcopy is stripping your elf clean already. It's set up in the rules too.
Re: decreasing executable size with gcc options
Yeah, so no need for -s switch.ritz wrote:To my knowledge, objcopy is stripping your elf clean already. It's set up in the rules too.
I dunno for you, but I'm not using Makefiles for day-to-day coding. I have set up a Code::Blocks project which is able to generate code for NDS or Windows (different targets). So I have an IDE to work. Makefiles are OK for other people when they want to recompile your work.
Who is online
Users browsing this forum: No registered users and 1 guest