public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: Jojo R <rjiejie@linux.alibaba.com>
Cc: newlib@sourceware.org
Subject: Re: Weak symbol for printf/scanf family
Date: Wed, 13 Apr 2022 01:27:54 -0400	[thread overview]
Message-ID: <YlZfWkdn+u6IK+sv@vapier> (raw)
In-Reply-To: <c98bbb6c-6e46-4706-98d9-8a1e817f6f9e@Spark>

[-- Attachment #1: Type: text/plain, Size: 1110 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-04-13  5:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <021a47e3-b78c-4481-8d9d-b8e746091932@Spark>
2022-04-11  2:50 ` Jojo R
2022-04-13  5:27   ` Mike Frysinger [this message]
2022-04-18  2:32     ` Jojo R

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YlZfWkdn+u6IK+sv@vapier \
    --to=vapier@gentoo.org \
    --cc=newlib@sourceware.org \
    --cc=rjiejie@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).