Cleanup for cryptographic algorithms vs. compiler optimizations

Bernd Walter ticso at
Sun Jun 13 12:07:28 UTC 2010

On Sun, Jun 13, 2010 at 12:44:03PM +0200, Matthias Andree wrote:
> Am 13.06.2010, 00:52 Uhr, schrieb Bernd Walter:
> >>In more general terms, the compiler is allowed to make any changes it
> >>likes to the program as long as the end result behaves exactly like it
> >>would if it hadn't been changed.  This is called the "as if" rule.  For
> >>instance, if you call printf() or fprintf() with a format string that
> >>does not contain any conversion specifiers, gcc will call gets() or
> >>fgets() instead.
> >
> >Amazing - this is one of the things which can get nasty if you try some
> >kind of microtuning.
> >Recently I had to implement my own atoi on a controller because using the
> >library one magically had blown my RAM usage by 1k on a controller with
> >just 8k RAM.
> There are certain compiler flags to affect that. For GCC, -Os is one  
> (which doesn't necessarily work in FreeBSD though, on some versions the  
> compiler would go into unterminated loop, leak memory and ultimately fail  
> with OOM), flags to tell the compiler that the implementation is  
> freestanding, and attributes to select builtins and the likes.

I know -Os - the problem was more complicated and at linker stage.
It was because atoi sucked more hardly related library parts in, of
which one had 1k static RAM requirement.
Quite surprising outcome from using atoi.
But this isn't related to FreeBSD at all, since it happened with newlibc.

B.Walter <bernd at>
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.

More information about the freebsd-current mailing list