wolfcw / libfaketime

libfaketime modifies the system time for a single application
https://github.com/wolfcw/libfaketime
GNU General Public License v2.0
2.64k stars 321 forks source link

[Question] Related to FORCE_PTHREAD_NONVER #398

Closed yerlandinata closed 2 years ago

yerlandinata commented 2 years ago

Hi,

Currently I'm working to upgrade libfaketime in chromeos package system to the latest version (0.9.10). However, I'm stumbling upon these linker errors:

ld.lld: error: libfaketimeMT.o: symbol pthread_cond_timedwait@@ has undefined version 
ld.lld: error: libfaketimeMT.o: symbol pthread_cond_init@@ has undefined version 
ld.lld: error: libfaketimeMT.o: symbol pthread_cond_destroy@@ has undefined version 

ld.lld: error: libfaketime.o: symbol pthread_cond_timedwait@@ has undefined version 
ld.lld: error: libfaketime.o: symbol pthread_cond_init@@ has undefined version 
ld.lld: error: libfaketime.o: symbol pthread_cond_destroy@@ has undefined version 

I see that this only happens when cross-compiling (I'm using cross-compilers) for arm target (arm & arm64), and I found this piece of codes that basically saying that all arm target must be using this "FORCE_PTHREAD_NONVER" (since this is the only use of FORCE_PTHREAD_NONVER)

#if defined __ARM_ARCH || defined FORCE_PTHREAD_NONVER
__asm__(".symver pthread_cond_timedwait_232, pthread_cond_timedwait@@");
__asm__(".symver pthread_cond_init_232, pthread_cond_init@@");
__asm__(".symver pthread_cond_destroy_232, pthread_cond_destroy@@");
#else
__asm__(".symver pthread_cond_timedwait_232, pthread_cond_timedwait@@GLIBC_2.3.2");
__asm__(".symver pthread_cond_init_232, pthread_cond_init@@GLIBC_2.3.2");
__asm__(".symver pthread_cond_destroy_232, pthread_cond_destroy@@GLIBC_2.3.2");
#endif

from the linker errors, what I see is the linker just don't understand where to find this "nonversioned" pthread related functions, is this interpretation accurate?

I know that by simply removing FAKE_PTHREAD from the compiler flags will make all these errors disappears ((while also making the fake pthread feature itself disappear)), but I'm very curious about this as from what I see, the codes can compile just fine on debian arm, arm64, etc. I'm wondering if there is something missing from our cross-compilers configuration or something.

I've looked up the documentations of linker version scripts and the .symver pseudo-op, but I just can't seem to understand the "base nonversion" part, do someone mind explaining what is happening in these asm line of codes?