Hi all,
I have a problem where i need to find to what library my code links to.
Here is the scenario:
a) I have two executables. Both link to pthread. But pthread seems to behave differently.
b) I am not sure that they are linking to the same version or the same pthread library.
c) Assuming there are different versions of the lib, i maybe linking to different libs.
d) Right now, i have no way to check this. The code size is massive and I don't know where to find linker paths etc..
So, here's what i did:
void print_func(void* code)
{
int i;
printf("\nFunc code:\n");
printf("\n==============================\n");
char* data = (char*)code;
for (i = 0; i < 100; i++) { //just print some 100 bytes in code definition.
printf(" %3d ", *data++);
}
printf("\n==============================\n");
}
void mut_init(pthread_mutex_t* mutp)
{
// Some init code..
// Print code.
{
// Print out code definitions for some pthread functions..
print_func(pthread_func_1);
print_func(pthread_func_2);
// Print the code defintion for printf..
print_func(printf);
}
}
I do the same for both executables. As I'd expected, the printf code definitions are the same(so, the libc library is the same), however the pthread code defintions seem to differ.
Now, my questions.
1) Is this a foolproof way to check that I'm linking to different libs?
2) If not, can you please explain what is wrong with this approach? It's just a quick experiment that i did.