Compile and use glibc-2.13 from source for ubuntu x86_64 architecture

1k views Asked by At

I am trying to build a modified version of libc/NPTL. My ubuntu version shows that it is version 2.13. I want to create a separate libc/nptl/libpthreads and want to use it for an existing application (like apache) using dynamic loading without replacing existing glibc/libpthreads. I am new to kernel programming and dynamic loading. Can you provide an example of how to use libc/NPTL using dynamic loading capability.

1

There are 1 answers

0
Employed Russian On BEST ANSWER

I want to create a separate libc/nptl/libpthreads

That's easy: ./configure --prefix=/u && make && make install. Congratulations, you now have a separate libc/lipthreads under /u

and want to use it for an existing application (like apache)

It's not quite clear whether you want to use your new libc with existing (prebuilt) binary, or with one you can rebuild.

If the latter, simply add -Wl,--dynamic-linker=/u/lib64/ld-linux-x86-64.so.2 (for 64-bit binaries), and you are done.

If the former, and the application does not execve itself, you can invoke it like this: /u/lib64/ld-linux-x86-64.so.2 /path/to/app.

If the application does exec itself, or gets invoked by multitude of shell scripts which you don't want to modify, then you'll have to binary-patch the application: replace /lib64/ld-linux-x86-64.so.2 string in the .dynstr section of the binary with /u/lib64/ld-2.13.so (new string has to be not longer than the old one).

I am new to kernel programming

Your question has nothing whatsoever to do with kernel programming.