Re: Weak symbol for printf/scanf family

Mike Frysinger <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <YlZfWkdn+u6IK+sv@vapier>
On 11 Apr 2022 10:50, Jojo R wrote:
> 	Dose anyone know why libc dose not use WEAK attribution for
> 	some symbols like printf/scanf family ?
> 
> 	Some developers want to reimplement sub sets of them maybe :)

weak symbols in static libs is generally a recipe for doom.  the linker won't
pull in objects from an archive unless there's a strong symbol pulling it in
which means weak refs effectively never get satisfied.  this is mitigated by
using --whole-archive, but that defeats the point of using a static lib with
newlib in the first place.

backing up a bit, newlib uses static linking, which means if your program
provided the printf symbol, either directly or in an object listed before
the -lc linkage, your printf symbol would be used first, and newlib's own
printf would not be pulled in.  if you're still seeing newlib's printf
being pulled in (and presumably causing duplicate symbol linker errors),
then something else is going on, and weak symbols wouldn't help.

but it's hard to say without a concrete example of what you're trying to
do and how it isn't working.
-mike
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmJWX1UACgkQQWM7n+g3
9YE0oxAAn5kt7PGUPNuJGqmzQGHn497VKcHcFsKGvZ8Atl5m0QFnUvtgq3T5+so8
4SvVMFwYpVmVxLYJqxIx62DuOvELAR25uhnX9BAb35Ykqr+bipg9BOkAHvkQrL5B
Ix8sPQCXcpRvO+CVldqhX/U/AvtkD33/1xyT+RrbJ+hRJYTE8mEksnj500ifCXLP
xWVWvIUdM63V2OFOlT8S1NcryzLM+Vz9FE75IqHeYefFk6GGnKzqJ76cJafGjWts
9Ke4nCilQorqC8YqcC7rpFi/XBExsHNHlfXZgDplN0oKkPmD4wUg9IxcIEr9DWpy
+vdzAtscm5XvT/ymBaD2I1VVpgEBlrlNhWHm1bfuEKp8y3kDqGvDNPQ7dRbbk6GG
DJBW30BC9cqoxhgB6itnVHVxX7YCd3Gunq6kjKSKGIFVNccqlJMfka9Ihwr61bEY
Gv2ypY2pqDpyIyYCmWmzjttPT/93WNx0BI3b7YEOxW/9v1Ulhq5xB6nfuRdpsi5V
lP+mCqAg841smHmHiPQGzvzqnmGldtEoljwSy69rYsY9tchw2djiBDjoR3caqbMb
akYExMwp6HjHU+hmkMDf1VEIng7QbeE11ZrgGgAeI4pPfC8p8zuJz1d9TpoJyN8J
I8z3cHvemTMkRRJLlAis83LgMrGwFGKXZqBHnoYo6FjdsMh7Dho=
=Fniq
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.