Issue with dynamically loading the glibc library
Florian Weimer
fweimer@redhat.com
Thu Jan 2 09:59:38 GMT 2025
* Joseph Lutz via Libc-help:
> On our 32-bit embedded system we have been working through our year
> 2038 problems. In one place we are using python to dynamically load
> the glibc library and call the clock_settime() function. The call is
> not working for dates after 2038. I used strace to see what the kernel
> is receiving and am noticing that it is passing the time as if it were
> a 32-bit integer even though we are compiling with _TIME_BITS=64 set.
At one point, we've discussed adding a __dlsym64 variant that
automatically looks up both symbols, but we decided against it in the
end. It's unclear if it would automatically solve your problem. If
your application uses ctypes, you'd still have to adjust the Python
version of the struct timespec type to make this work.
> I dug into this more by creating a couple small C programs. One
> program dynamically loads and then calls the clock_settime() function
> in glibc. This program passes the time as a 64-bit integer to the
> kernel and sets the system date correctly. The other program
> dynamically loads glibc and then used that to call the clock_settime()
> function. This program returns an error and dose not set the system
> date. It passes the time_t value as if it were a 32-bit integer.
>
> The version of glibc we are compiling is 2.35 and readelf shows the
> following:
>
> $ readelf --dyn-syms -W ./libc.so | grep clock_settime
> 150: 000aed88 292 FUNC GLOBAL DEFAULT 13 __clock_settime64@@GLIBC_2.34
> 1055: 000aeeac 44 FUNC GLOBAL DEFAULT 13 clock_settime@GLIBC_2.4
> 1056: 000aeeac 44 FUNC GLOBAL DEFAULT 13 clock_settime@@GLIBC_2.17
>
> It is my guess that the default ABI (clock_settime@@GLIBC_2.17) treats
> the time_t as if it were a 32-bit integer.
> If my guess is correct is there a way that the
> clock_settime@@GLIBC_2.17 can be removed or the default be changed to
> the clock_settime@GLIBC_2.4?
These two functions are already the same, see the address in the second
column of the readelf output.
If you want to switch the default to __clock_settime64, that's
effectively a new ABI.
Thanks,
Florian
More information about the Libc-help
mailing list