I have this simple c-code
It works fine when i link it as
gcc -g app.c.o -o app -lrt -lpthread -lc
But if we change order of linking libc and libthread
gcc -g app.c.o -o app -lrt -lc -lpthread
it does not work.
We know on FreeBSD stubs of pthread-functions in libc are made as weak reference. For example
objdump -T /lib/libc.so.7 | grep pthread_cond_signal
00000000000e2bf0 w DF .text 0000000000000011 FBSD_1.0 pthread_cond_signal
It means order of linking is not matter. Why so?