This is the mail archive of the
mailing list for the newlib project.
RE: selective linking of floating point support for *printf / *scanf
- From: "Thomas Preud'homme" <thomas dot preudhomme at arm dot com>
- To: "'Joern Rennecke'" <joern dot rennecke at embecosm dot com>
- Cc: "GCC" <gcc at gcc dot gnu dot org>, "Joerg Wunsch" <joerg_wunsch at uriah dot heep dot sax dot de>, <avr-libc-dev at nongnu dot org>, "Andrew Burgess" <andrew dot burgess at embecosm dot com>, <newlib at sourceware dot org>
- Date: Wed, 27 Aug 2014 15:02:02 +0800
- Subject: RE: selective linking of floating point support for *printf / *scanf
- Authentication-results: sourceware.org; auth=none
- References: <CAMqJFCpWKXVmmc-YLKf9XO6H8C_YnTEcgzkJAidE21MirJbi-w at mail dot gmail dot com> <001401cfc0f9$bdc5cbc0$39516340$ at arm dot com> <CAMqJFCrEOgavwvW25vO=S-+0TZ_xOnDa0Ex-Ff4XG329K5WE9g at mail dot gmail dot com>
> From: Joern Rennecke [mailto:email@example.com]
> Sent: Tuesday, August 26, 2014 6:44 PM
> Due to the library order defined in the specs, the float-enbled printf
> definition will
> be picked up from libprintf_flt.a .
It seems to me that it relies heavily on how symbol resolution works. If
I understand correctly all undefined symbols (for instance __int_printf)
in object files are processed first. Symbols definition are search in the
order in which libraries are given in the command line (this part seems
pretty reliable since it's at least documented in ld's manual). When
doing so, if a symbol definition reference an undefined symbol (like
__int_printf referencing printf), it is left aside until all undefined
symbol from object files have been processed. At some point printf
from object file will be processed and will pull the printf with float
support since it's the first one encountered. Then the undefined
reference discovered when pulling symbols from library will be
processed and since printf with float was already pulled in that's
the one being used.
Is this behavior the same for all linker? It sounds like a reasonable
algorithm but I don't know well the variety of linkers out there.
> That testcase is not valid. You'd to use one of the v*printf functions.
> Solving the general problem for these is not computable; for specific cases, it
> would be possible, but at the cost of varying degrees of complexity.
> So I let this for manual selection: it's not handled with the
> hook, and you have to use a special link line to use the integer-only
> Well, if desired, a spec change could give an option to do that.
Right, my bad, no problem indeed. What "general problem" are you
referring too that is not solved with this patch?
> That can be implemented with suitable *newlib*.[ch] files that are
> selected in config.gcc,
> akin to newlib-stdint.h and glibc-c.c .
Absolutely, that was the approach I followed in my own patch.
> Well, all the *printf functions are variadic, and as stated above,
> your example is invalid.
> The wildcard are va_list taking functions. You first have to decide
> what you want to
> happen with these by default, and what kind of non-default behaviour
> you'd like to be
> able to select, and how; than we can talk about if this neeeds any
> extra infrastructure
> to implement.
Yes my apologize, it was a mistake from me.
I'll now do a more thorough testing and report back to you how it works for