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.

DS development > Eliminating __aeabi_atexit?

#149372 - Dwedit - Sat Jan 19, 2008 9:15 am

I'm working on a C++ program.
The linker loves to add a handler to call destructors when the program finishes because there are static or global objects. Here, it's adding __aeabi_atexit, and it's big group of friends to handle destruction of those objects when the program exits.
Exits? Where? How does an NDS program exit?

So I'm making a dummy function here
Code:
extern "C" {
   void __aeabi_atexit()
   {
      
   }
}

to make the linker not include code for __aeabi_atexit, and this actually works.

Is there a better way to do this which is not a complete and utter hack?
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#149404 - tepples - Sat Jan 19, 2008 7:48 pm

Dwedit wrote:
How does an NDS program exit?

Eventually, a program will exit using something like bootlib.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#149410 - sajiimori - Sat Jan 19, 2008 8:49 pm

I somehow doubt that bootlib scans binaries to find their atexit code and executes it before resetting. The term "memory leak" sort of loses its meaning when you're destroying the program that contains the memory allocation system -- atexit is something of a foregone conclusion.

The solution you've got there looks good to me, Dwedit!

#149446 - Dwedit - Sun Jan 20, 2008 3:32 am

Maybe add it into the CRT instead of into the code?
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."