3

I want to find out which compiler/linker options were used to compile the GNU C Standard Library (glibc) when installing Linux. In particular I want to get the same result of the archive libc.a when compiling glibc from source on a different machine (same version of gcc, make, binutils, etc though).

All I could find out was the used gcc version with:

user@ubuntu:/$ /lib/x86_64-linux-gnu/libc.so.6 
GNU C Library (Ubuntu GLIBC 2.21-0ubuntu4) stable release version 2.21,
...
Compiled by GNU CC version 4.9.2.
...

But when compiling glibc from source with no further options I don't get the same results after running make. The self compiled libc.a archive is different from the preinstalled one (size and binary wise). So I guess there is some optimization going on. Maybe because of included debug information when compiled from source.

Build:

user@ubuntu:~/glibc$ sudo apt-get source libc6
user@ubuntu:~/glibc/glibc-build$ sudo ../glibc-2.21/configure --prefix=/home/user/glibc/glibc-install/
...
sudo make
...

In the debian/rules file and in the output I found, that -O2 and -g is used with gcc.

There is an existing question, which I looked at but didn't help me.

I am currently using Ubuntu 15.04, but I need it on other (non debian) systems also. Furthermore it should also work with eglibc on Ubuntu 14.04.


The final goal is to reproduce (compile) every version of glibc used on different systems (I know that's a lot) and make IDA PRO FLIRT signatures out of them. So, in conclusion I need the same binary output at least for libc.a (that's the file the signatures are made from). Further reading on FLIRT Signatures here.

The Problem with these Signatures is, that every different compiler version and every compiler option can change the output of the Library archive and lead to a different Signature which will only partially work on the analyzed binary.

I'm new to this, so every help is welcome. I hope i didn't forget to mention something important.

0

You should find everything you need to rebuild in the src.deb package that matches you .deb package. Look at apt-src(8).

  • What's the difference of using apt-src compared to apt-get source and then running make beside of having a .deb file for the installation? – BACH Sep 28 '15 at 13:05
  • Well, I tried it and apparently the libc.a in the .deb file has exactly the same size but a different md5 sum. I'll try creating FLIRT Signatures now and see if they're the same. Btw. building the .deb files took a lot of time. – BACH Sep 28 '15 at 14:59
  • Can you validate my answer if it helped you to rebuild your binary with the same options ? – Vinz Sep 28 '15 at 15:31
  • I want to test different versions and systems too, and it worked also with downloading apt-get download libc6-dev (same md5 hashes also). My Problem is that I still don't know the compilation options, which was the original question. – BACH Sep 28 '15 at 15:39
  • The compilations options are in the source package. Unpack the package, then have a look at the debian/rules file. You should find the options used to compile. – Vinz Sep 28 '15 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.