Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda