public inbox for gnu-gabi@sourceware.org
 help / color / mirror / Atom feed
From: James Y Knight <jyknight@google.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: Jozef Lawrynowicz <jozef.l@mittosystems.com>, gnu-gabi@sourceware.org
Subject: Re: [RFC] Proposal for new ELF extension - "Symbol meta-information"
Date: Mon, 31 Aug 2020 09:45:36 -0400	[thread overview]
Message-ID: <CAA2zVHqQ32e8vKcOghq+ssevHGyGnBPsqCOJa7bPCBKCQxvQLw@mail.gmail.com> (raw)
In-Reply-To: <875z8zj95u.fsf@oldenburg2.str.redhat.com>

On Mon, Aug 31, 2020 at 8:24 AM Florian Weimer via Gnu-gabi <
gnu-gabi@sourceware.org> wrote:

> >     3.3.3 SMT_PRINTF_FMT use case
>
> Can this achieved in C++ with a library-only solution?  So that
>   printf ("%s", str);
> and
>   printf ("%f", num);
> resolve to different printf symbols externally?
>

The LLVM backend optimizer already does this automatically for XCore, TCE,
and Emscripten targets, without interrogating the format string, or adding
anything to the object format.

On all three: if there are no floating-point arguments to the call, it will
translate {s,f,}printf -> i{s,f,}printf. Otherwise, on emscripten only, if
there are no 128-bit float arguments, it will translate {s,f,}printf ->
small_{s,f,}printf

MSVC (and therefore also LLVM targeting windows) uses a slightly different
scheme: the compiler emits a reference to a global "_fltused" whenever
there's any floating-point instructions in the program (related to printf
or not). Then, the undefined reference to that symbol pulls in the
floating-point support for printf/scanf in the MS libc.

  parent reply	other threads:[~2020-08-31 13:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31 11:58 Jozef Lawrynowicz
2020-08-31 12:23 ` Florian Weimer
2020-08-31 13:14   ` Jozef Lawrynowicz
2020-08-31 13:45   ` James Y Knight [this message]
2020-09-01 11:20     ` Florian Weimer
2020-09-01 12:19       ` Jozef Lawrynowicz
2020-09-01 12:48         ` Florian Weimer
2020-09-02 10:26           ` Jozef Lawrynowicz
2020-09-03 16:49             ` Jozef Lawrynowicz

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=CAA2zVHqQ32e8vKcOghq+ssevHGyGnBPsqCOJa7bPCBKCQxvQLw@mail.gmail.com \
    --to=jyknight@google.com \
    --cc=fweimer@redhat.com \
    --cc=gnu-gabi@sourceware.org \
    --cc=jozef.l@mittosystems.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).