This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RE: PATCH: Disable dynamic allocation in atexit
- From: "Schwarz, Konrad" <konrad dot schwarz at siemens dot com>
- To: "Richard Earnshaw" <rearnsha at arm dot com>, "Mark Mitchell" <mark at codesourcery dot com>
- Cc: "Jeff Johnston" <jjohnstn at redhat dot com>, <newlib at sources dot redhat dot com>
- Date: Tue, 21 Mar 2006 12:37:18 +0100
- Subject: RE: PATCH: Disable dynamic allocation in atexit
> -----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().