This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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().


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]