lks9 / src-tracer

Other
0 stars 0 forks source link

libsrc_tracer not automatically loaded after instrumenting musl #48

Open lks9 opened 1 year ago

lks9 commented 1 year ago

I managed to install alpine linux (see #20) with an instrumented musl libc for tracing. This does not yet start recording, since the applications need to start recording explicitely.

The only problem: I now get segfaults for some applications (the system still starts without an issue). This is because libsrc_tracer.a is not loaded by musl or the application. But the instrumented musl still refers to _trace* symbols.

Solution: Compile libsrc_tracer into either gcc's libgcc or musl's libc. Since libgcc is loaded unconditionally for all applications, this should be fine.

Edit: I compiled libsrc_tracer into gcc's libgcc, it took one day and in the end it vanished, apparently compiled away. Argh!

lks9 commented 1 year ago

I managed to put the src_tracer.c inside musl:

cd ~/musl/src/
mkdir src_tracer/
cp ~/src-tracer/lib/src_tracer.c src_tracer/
cd ~/musl/include
mkdir src_tracer/
cp ~/src-tracer/include/* src_tracer/

Then run configure, make, etc.

I tested it on alpine linux, it worked well, but some apps like gdb and firefox received a segmentation fault nontheless. And I couldn't debug them with gdb, because of the segv.