When I use objdump with -S flag, it produces the source code aligned with the corresponding assembly code. For example:
I want similar source code information for the library functions included in the code. For example, when I use “pthread_create” in the program, the objdump produces only the assembly code for the pthread_create function. It does not mix in the source code info. How do I enable that? Do I need to re-make the gcc compiler? What flags do I need?
An example source code that I am trying to do this:
#include <stdio.h>
#include <pthread.h>
#define MAX 16
#define MAX_THREAD 4
int sum[MAX_THREAD] = { 0 };
void sum_array(int i)
{
sum[i]= i;
}
int main()
{
pthread_t threads[MAX_THREAD];
// Creating 4 threads
for (int i = 0; i < MAX_THREAD; i++)
{
pthread_create(&threads[i], NULL, sum_array, i);
}
for (int i = 0; i < MAX_THREAD; i++)
{
pthread_join(threads[i], NULL);
}
return 0;
}
The compile commands I used:
gcc -static -g pthread.c -o pthread_musl_debuginfo
objdump -x –source –full-contents -D -S pthread_musl_debuginfo >
pthread_musl_debuginfo_objdump