pythonic
pythonic

Reputation: 21635

Changing glibc but nothing happens

I want to modify glibc. So I have downloaded a version of it and made some changes in the code. For example I've made changes to memset. However, I don't see any difference if I use the .so file produced by the compilation (using LD_PRELOAD) as compared to when I don't do any LD_PRELOAD. memset behaves like it does. Why is that so? Is that maybe the compiler is inlining memset and not using anything from the shared object? I don't understand this. I even made changes to printf, but still nothing. Why is that so. How can I modify glibc (for testing purposes), so that I do see a change?

Moreover, when I tried to change pthread_create (and ofcourse LD_PRELOAded libpthread.so) by introducing printf( "pthread_create") in the beginning of that function, I just get a segmentation fault. What is going on here? Also if I check the difference in the libc.so after making changes in glibc source, I see no difference in the produced versions. What is happening here. This is driving me nuts!

Upvotes: 2

Views: 268

Answers (1)

Frédéric Hamidi
Frédéric Hamidi

Reputation: 263047

GCC provides built-in versions of several functions, including memset() and printf(). It does not link to glibc's implementation of these functions.

Try passing the -fno-builtin compiler option to inhibit this behavior.

Upvotes: 4

Related Questions