This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Internal use of vsnprintf


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
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]