[patch] Remove --disable-newlib-atexit-alloc.

Jeff Johnston jjohnstn@redhat.com
Fri Nov 7 16:13:00 GMT 2008

Ralf Corsepius wrote:
> On Wed, 2008-11-05 at 19:30 -0800, Kazu Hirata wrote:
>> Hi,
>> Attached is a patch to remove --disable-newlib-atexit-alloc and make
>> malloc a weak symbol in the support functions for atexit.
>> A while ago, Mark Mitchell added --disable-newlib-atexit-dynamic-alloc
>> to prevent atexit from pulling malloc.  This was a bit inflexible
>> because once newlib was built with --disable-newlib-atexit-alloc, the
>> user couldn't enable malloc without rebuilding newlib.
>> This patch makes malloc a weak symbol in the support functions of
>> atexit.  This way, if malloc is available for some other reason, we
>> use that.  Otherwise, we don't to conserve space.
>> OK to apply?
> I am not sure, for 2 (hypothetical) reasons:
> * You can't be sure weak symbols are available on a particular target.
> newlib is being used for embedded targets, often using antiquated
> compilers and "odd" object formats.
> * The syntax you are using presumes using GCC.
> I am not aware about anybody using newlib without GCC, but you never
> know.
> Ralf
Agreed.  The current option should be left in place, but if you wanted 
to add a 2nd mechanism that doesn't require the option, that would be fine.

There is an _ATTRIBUTE macro defined in _ansi.h which can be used which 
will ignore any attributes for non __GNUC__ compilers or you could also 
make the __GNUC__ check yourself.  As well, the weak attribute should be 
specified as __weak__ to avoid any user-conflict.

-- Jeff J.

More information about the Newlib mailing list