From: Florian Weimer <fweimer@redhat.com>
To: James Y Knight via Gnu-gabi <gnu-gabi@sourceware.org>
Subject: Re: [RFC] Proposal for new ELF extension - "Symbol meta-information"
Date: Tue, 01 Sep 2020 13:20:16 +0200 [thread overview]
Message-ID: <87sgc1u4jz.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <CAA2zVHqQ32e8vKcOghq+ssevHGyGnBPsqCOJa7bPCBKCQxvQLw@mail.gmail.com> (James Y. Knight via Gnu-gabi's message of "Mon, 31 Aug 2020 09:45:36 -0400")
* James Y. Knight via Gnu-gabi:
> 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
It's not what I had in mind with my C++ comment (I thought about using a
constexpr construct to parse the format strings), but it's simpler to
just look at the types.
I think we could guide this by some attribute machinery for C,
especially if it is completely type-dependent. If the symbol choice is
determined by that, it is not necessary to maintain the symbol selection
in very different places (the library implementation *and* the linker).
This is main thing I do not like about SMT_PRINTF_FMT: it needs very
library-specific code in the link editor.
Thanks,
Florian
next prev parent reply other threads:[~2020-09-01 11:20 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
2020-09-01 11:20 ` Florian Weimer [this message]
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=87sgc1u4jz.fsf@oldenburg2.str.redhat.com \
--to=fweimer@redhat.com \
--cc=gnu-gabi@sourceware.org \
/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).