This is the mail archive of the
mailing list for the glibc project.
Re: Internal use of vsnprintf
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 3 May 2016 16:57:29 +0000
- Subject: Re: Internal use of vsnprintf
- Authentication-results: sourceware.org; auth=none
- References: <5728D6CD dot 60509 at redhat dot com>
On Tue, 3 May 2016, Florian Weimer wrote:
> How do I do that? We have an __vsnprintf definition in include/stdio.h, but I
> can't find a libc_hidden_proto/libc_hidden_define for it, and I get a PLT
> check failure as a result if I use it.
Because __vsnprintf is an exported symbol (in libio/Versions).
> Or should I call _IO_vsnprintf instead (which is what the snprintf
> implementation does)? I don't see the usual PLT avoidance stuff in the
> sources for _IO_vsnprintf, but it does happen. So how does it work?
If you call a function that's not exported from a shared library, then
properly you should also declare it with attribute_hidden to get the same
optimization as you get for an exported function using libc_hidden_* (you
can use libc_hidden_* to create and use aliases for a non-exported
function, that's just unnecessarily complicated compared to declaring it
hidden). For most architectures this doesn't matter (you don't get any
better optimization that way), but declaring it hidden helps for 32-bit
x86, where the ABI means a call to a function known at compile time to be
in the same shared library can be more efficient (see bug 18822).
Joseph S. Myers