gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Section usage information

#48681 - Glow - Thu Jul 21, 2005 7:15 pm

Hi there, I'm currently coding my first thingies for the GBA in C (and a bit in asm) using devkitARM, and until now I've put all the code that should run as fast as possible in IWRAM.

But I'd like to know if it's possible to get a list of how much bytes I've 'used' of the IWRAM? I thought I read somewhere that gcc is capable of generating such a list after linking...

I think I could append some magic value to all my code in IWRAM and then look it up in VBA's memory viewer, but hopefully there's an easier way of doing it.

- cheers, Glow.

#48684 - poslundc - Thu Jul 21, 2005 7:42 pm

You can generate a map file if you pass the "-Map outputfilename.map" option to GCC at the linking stage.

Alternatively, you can use the nm command-line utility (its part of the binutils that come with GCC) on your .elf file to get a list of memory objects. Pass it the "-n" option to get them ordered numerically. I usually find this option to be quicker and easier than reading a map file.

Dan.

#48685 - tepples - Thu Jul 21, 2005 7:48 pm

If you use makefiles, toss this in your makefile and then make your default target depend on, say, mario.map.txt:
Code:
%.map.txt: %.elf
   nm -n $< > $@

(You'll have to fix the tab if you're using copy and paste.)
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#48693 - Glow - Thu Jul 21, 2005 8:22 pm

Ah, cool, that's exactly what I needed :)

I think I'll use nm too, seems to give just the info that I need. Ohw, and I've also updated my makefile, as tepples suggested. Works great.

Thanx for the help guys.