Glibc change not working

I downloaded glibc to modify my code and then use it. So for the sake of playing with him, I changed the printf function in the stdio-common glibc directory to print "Can you see me?".

int
__printf (const char *format, ...)
{
  va_list arg;
  int done;

  va_start (arg, format);
  done = vfprintf (stdout, "Can you see me?", arg);
  va_end (arg);

  return done;
}

After making this change, I compiled glibc and then used LD_PRELOAD with libc.so in this glibc directory to run the sample program using printf. However, I still see printf printing normally, that is, the change I made is not reflected. What mistake am I making here?

+3
source share
1 answer

There may be several reasons for this. The simplest thing is that you used a string without a real format, and the compiler changed the call from printfto puts:

printf("hello\n");
// becomes:
puts("hello");

Try adding a parameter:

char ex = '!';
printf("Hello %c\n", ex);
+1
source

All Articles