PATCH: Disable dynamic allocation in atexit
Schwarz, Konrad
konrad.schwarz@siemens.com
Tue Mar 21 17:20:00 GMT 2006
> -----Original Message-----
> From: newlib-owner@sourceware.org
> Would it be reasonable to make atexit weakly reference
> malloc, and only call it if it's been linked in? I can't
> imagine that there would be many applications that would blow
> the static atexit table that wouldn't call malloc at least
> once from some other location.
Actually, I think this would be a neat idea.
If such a program actually slipped through, the atexit() function could
output a helpful message explaining that you need to reference malloc()
somehow (e.g., -u malloc on the linker command line), the C++ generated
code would then presumably terminate the program. Of course, this would
require e.g., a working stderr to actually see the message :-).
Thinking further, this would probably require changes to stdio to also
reference malloc only weakly, which would also be a good deal all
around, you could then have small systems use stdio; they can register
their static buffers using setvbuf().
More information about the Newlib
mailing list