This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: __statfs64() is declared but not defined
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: Peter TB Brett <peter at peter-b dot co dot uk>
- Cc: "libc-help at sourceware dot org" <libc-help at sourceware dot org>
- Date: Sat, 12 Apr 2014 13:02:37 -0400
- Subject: Re: __statfs64() is declared but not defined
- Authentication-results: sourceware.org; auth=none
- References: <871tx31s0i dot fsf at harrington dot peter-b dot co dot uk>
On Fri, Apr 11, 2014 at 5:21 PM, Peter TB Brett <peter@peter-b.co.uk> wrote:
> I'm relatively new to the glibc source code, so please bear with me --
> this is probably a very basic question!
Welcome Peter! Any question is a good question to ask on libc-help,
and it leaves an archive for others to look at.
> I'm currently hacking around in shm_open(), trying to change __statfs()
> calls to use __statfs64(), as suggested in [BZ 15514].
> When I make the naive change and try to compile the library, shm_open.c
> gets compiled to an object successfully, but the linker fails with:
>
> undefined reference to `__statfs64'
>
> If I change the __statfs64() calls to us statfs64() instead, compilation
> is successful.
>
> Clearly, the header files used during compilation declare __statfs64(),
> but no definition gets included in the object files.
>
> Am I missing something obvious here?
Yes.
The shm_open function is part of librt.so and not libc.so.6.
Therefore the __statfs64() function call is not available to link
against from an external library like librt.so.
Internally libc.so.6 may use __statfs64 to avoid PLT indirection and
call this function directly for performance reasons and internal
consistency reasons. Sometimes we do this to ignore user provided
interposed versions of functions where internal consistency is more
important e.g. we really really need to stat a file to implement some
other API without having the users version of stat get in the way
(this decision is made on a case by case basis).
However, from librt.so, we must go through the PLT to reach statfs64
in libc.so.6 and can't avoid that without providing a GLIBC_PRIVATE
version of the symbol for librt.so to call. We don't do that because
there is no need.
To make a long story short you should just call statfs64.
Does that answer your question?
Cheers,
Carlos.