Search code examples
gccelfobjdump

Cannot reproduce building static library


I create a static library (libxil.a) (more precisely Xilinx's SDK generates a static library from BSP sources)

I realized that running make twice on the same sources produces different libxil.a. (The md5sum-s are different):

$ make
...

$ md5sum libxil.a
66f2a981ba0e608b4747d59c8d706561  libxil.a

$ make clean

$ make
...

$ md5sum libxil.a
ba26dba2211e539d0f17d9a4464b3386 libxil.a

I tried to view the difference with objdump -s, but nothing:

diff  <(objdump -s libxil1.a) <(objdump -s libxil2.a)

(-s Display the full contents of all sections requested)

How can I view the difference?

Why the two compilation differs at all?


Solution

  • The -s switch of objdump does not dump the headers. Use -x switch too, which "Display the contents of all headers"

    $ diff  <(objdump -sx libxil1.a) <(objdump -sx libxil2.a)
    ...
    4c4
    < rw-rw-r-- 1008/1008   1324 Jul 24 10:36 2020 xio.o
    ---
    > rw-rw-r-- 1008/1008   1324 Jul 24 10:46 2020 xio.o
    ...
    

    A static library stores the creation date of the object files. And these timestamps differ compilation by compilation.