Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

119
Vistas
Difference in md5sums in two object files

I compile twice the same .c and .h files and get object files with the same size but different md5sums. Here is the only difference from objdump -d:

1) cpcidskephemerissegment.o: file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <_ZN68_GLOBAL__N_sdk_segment_cpcidskephemerissegment.cpp_00000000_B8B9E66611MinFunctionEii>:

2) cpcidskephemerissegment.o: file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <_ZN68_GLOBAL__N_sdk_segment_cpcidskephemerissegment.cpp_00000000_8B65537811MinFunctionEii>:

What can be the reason? Thanks!

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

The reasons can be many:

  • Using macros like __DATE__ and __TIME__
  • Embedding counters that are incremented for each build (the Linux kernel does this)
  • Timestamps (or similarly variable quantities) embedded in the .comments ELF section. One example of a compiler that does this is the xlC compiler on AIX.
  • Different names as a result of name mangling (e.g. C++)
  • Changes in environment variables which are affecting the build process.
  • Compiler bug(s) (however unlikely)

To produce bit identical builds, you can use GCC's -frandom-seed parameter. There were situations where it could break things before GCC 4.3, but GCC now turns functions defined in anonymous namespaces into static symbols. However, you will always be safe if you compile each file using a different value for -frandom-seed, the simplest way being to use the filename itself as the seed.

over 4 years ago · Santiago Trujillo Denunciar

0

I guess, the compiler didn't know how to name this namespace and used path to the source file plus some random number.

The compiler must guarantee that a symbol in unnamed namespace does not conflict with any other symbol in your program. By default this is achieved by taking full filename of the source, and appending a random hash value to it (it's legal to compile the same source twice (e.g. with different macros) and link the two objects into a single program, and the unnamed namespace symbols must still be distinct, so using just the source filename without the seed is not enough).

If you know that you are not linking the same source file more than once, and want to have a bit-identical object file on re-compile, the solution is to add -frandom-seed="abcd" to your compile line (replace "abcd" with anything you want; it's common to use the filename as the value of random seed). Documentation here.

over 4 years ago · Santiago Trujillo Denunciar

0

Finally I've found the answer!

c++filt command gave the original name of the function:

{unnamed namespace}: MinFunction(int, int)

In the source was:

namespace
{
MinFunction(int a, int b) { ... }
}

I named the namespace and got stable checksum of object file! As I guess, the compiler didn't know how to name this namespace and used path to the source file plus some random number.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda