Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » AVR-GCC
  • » [avr-libc-dev] Re: [avr-gcc-list] Poll: Who uses itoa() & co with base != {2, 8, 10, 16}? [RSS Feed]

#1 Nov. 19, 2005 12:22:40

Daniel O.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-libc-dev] Re: [avr-gcc-list] Poll: Who uses itoa() & co with base != {2, 8, 10, 16}?


On Sat, 19 Nov 2005 21:04, Russell Shaw wrote:
> > It will if it's implemented correctly, eg in stdlib.h
> >
> > #ifdef _USE_FULL_ITOA
> > #define itoa _itoa_full
> > #else
> > #define itoa _itoa_small
> > #endif
>
> Even if functions are unused in a library that is linked, don't they still
> end up in the final binary?

No, they don't, otherwise you'd run out of flash space all the time :)

--
Daniel O'Connor software and network engineer
for Genesis Software -http://www.gsoft.com.au"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8CpgpHqZRxFmCdF.pgpDescription:PGP signature_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Attachments:
attachment pgpHqZRxFmCdF.pgp (187 bytes)

Offline

#2 Nov. 19, 2005 13:54:31

Rolf E.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-libc-dev] Re: [avr-gcc-list] Poll: Who uses itoa() & co with base != {2, 8, 10, 16}?


Even if functions are unused in a library that is linked, don't theystill end up in the final binary?No, they don't, otherwise you'd run out of flash space all the time :)itoa and itoa_full in separate .o files => only the used one gets linked.

itoa and itoa_full in the same .o file => both are in the flash file.if you use -ffunction_sections and -Wl,--gc-sections in the latter casethen the linker also strips unused functions from the flash fileRolf


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Offline

#3 Nov. 19, 2005 19:09:15

Joerg W.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-libc-dev] Re: [avr-gcc-list] Poll: Who uses itoa() & co with base != {2, 8, 10, 16}?


As Rolf Ebert wrote:

> if you use -ffunction_sections and -Wl,--gc-sections in the latter
> case then the linker also strips unused functions from the flash
> file

Except these source files are assembly code. ;-) The source would need
to take care to place each function into a subsection of its own.

These are somewhat interweaved actually, e.g. itoa_fast and
itoa_fast_width (IIRC) would share the same source code (they
are just different entries into the same code). But yes, the
standard (slow) itoa functions would be in a different object
module, thus normally not linked (and subsequently, if no other
division was used inside the program, the division subroutine
would be avoided as well).

--
cheers, J"org .-.-. --... ...-- -.. . DL8DTLhttp://www.sax.de/~joerg/NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Offline

#4 Nov. 19, 2005 19:17:52

Joerg W.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-libc-dev] Re: [avr-gcc-list] Poll: Who uses itoa() & co with base != {2, 8, 10, 16}?


As Russell Shaw wrote:

> I never noticed, because i always write my own minimal versions of
> things.

>http://lists.nongnu.org/archive/html/avr-gcc-list/2002-07/msg00063.htmlBtw., in that case, I think even the logic behind -ffunction-sections
and -gc-unused-sections would fail: your foo() recursively called
itself, so I guess the linker would recognize this as the symbol foo
(and thus the section) being used, and thus not being gc-able -- even
though nobody would really call foo() from outside.

Situations like these are one of the reasons why I think it would be
better to leave it to a human (i.e. the developer) to rather design
the entire system in a way where he knows that only those parts of the
program that belong into it will really be linked, instead of (to
exaggerate quite a bit) hacking together whatever he just feels like,
and then hoping the tools will eventually sort his mess out.

--
cheers, J"org .-.-. --... ...-- -.. . DL8DTLhttp://www.sax.de/~joerg/NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Offline

  • Root
  • » AVR-GCC
  • » [avr-libc-dev] Re: [avr-gcc-list] Poll: Who uses itoa() & co with base != {2, 8, 10, 16}? [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support