From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 251603858D28 for ; Wed, 13 Apr 2022 05:27:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 251603858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 3786B341C2B; Wed, 13 Apr 2022 05:27:35 +0000 (UTC) Date: Wed, 13 Apr 2022 01:27:54 -0400 From: Mike Frysinger To: Jojo R Cc: newlib@sourceware.org Subject: Re: Weak symbol for printf/scanf family Message-ID: Mail-Followup-To: Jojo R , newlib@sourceware.org References: <021a47e3-b78c-4481-8d9d-b8e746091932@Spark> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="f4dy05iTl3C1Gfuo" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Apr 2022 05:27:37 -0000 --f4dy05iTl3C1Gfuo Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 ? >=20 > 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 --f4dy05iTl3C1Gfuo Content-Type: application/pgp-signature; name="signature.asc" -----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----- --f4dy05iTl3C1Gfuo--