1

ltrace doesn't work on binaries linked with the -z now option—Check this question—which is the default on my Ubuntu 19.10 system. It only works on binaries linked with -z lazy.

Is there any alternative to ltrace that does the same job, but works on lazily linked binaries also?

bu5hman
  • 4,663
  • 2
  • 14
  • 29
SkullTech
  • 161
  • 5

1 Answers1

2

This question was answered here. I'll post a summary.

The uftrace utility is a valid alternative to ltrace that works on binaries linked with -z now. Below is a demonstration.

#include <stdio.h>

int main(int argc, char const *argv[])
{
    printf("Hello world!\n");
    return 0;
}

We'll be using the above hello world program for demonstration purposes.

sumit@HAL9000:~$ gcc hello.c -o hello -Wl,-z,now
sumit@HAL9000:~$ ltrace ./hello 
Hello world!
+++ exited (status 0) +++
sumit@HAL9000:~$ uftrace --force -a ./hello
Hello world!
# DURATION     TID     FUNCTION
 187.291 us [ 40352] | puts("Hello world!") = 13;

As we can see above, ltrace didn't work on the program when it was compiled with -z now, but uftrace did.

SkullTech
  • 161
  • 5