This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compare linked object

Hi, We use C6000 compiler in our project, we wants to use the objdiff tool to compare the objects built and determined only the changed objects to be delivered, in our projects, the final deliver are the BIN files, from source code to BIN files it covers:

Source file(*.cpp) ---->(1)Object file (*.obj)---->(2) archive lib(*.lib)----> (3)linked out files(*.out) ----> (4)packed BIN files (*.BIN)

NOTE: (3) linked out files(*.out), during linking, it used the *.lib from (2) and also libs from other folder;

If we rebuilt the same code in the same build environment, by using the objdiff we can compare the *.obj are the same,  some *.lib are different, and compared the linked *.out files and BIN files, they are different,  is there any way to compare the *.out and *BIN files. Otherwise we are not able to tell the BIN are the same if the *.obj are the same.

Could someone advise if you have experience as this case? thanks.

  • "out" files (executable object files) can be compared with objdiff as well.

    In what format are your BIN files?

  • Hi,

    Out files are: ELF 32-bit LSB executable, version 1 (SYSV), statically linked, not stripped

    but we saw there are a couple of difference when comparing the out files.

    for the BIN files, we use an in-house tool to pack the *map, *.out files to the BIN files following a certain format

  • Hi,

    I even found some difference for two obj files with ".text section", they are compiled using the same code and same build environment, even exactly the same workspace path by one after another compiled.

    Comparing Sections : section = .text:_ZN45_GLOBAL__N__21_CStatMeasInstance_cpp_de4062607emplaceIN3lom2lb11CounterWrapINS2_10CounterCmpIjSt7greaterIjEEEEEEEPT_RNS1_11byte_streamE : elf32_shdr
    ======================================================================
             Differences: CStatMeasInstance1.obj    CStatMeasInstance2.obj
          sh_name_string: .text:_ZN45_GLOBAL__N__21_CStatMeasInstance_cpp_de4062607emplaceIN3lom2lb11CounterWrapINS2_10CounterCmpIjSt7greaterIjEEEEEEEPT_RNS1_11byte_streamE   .text:_ZN45_GLOBAL__N__21_CStatMeasInstance_cpp_2372d2807emplaceIN3lom2lb11CounterWrapINS2_10CounterCmpIjSt7greaterIjEEEEEEEPT_RNS1_11byte_streamE

    if I understand correctly, the .text section shall not be skipped as it contains all the executable code, then how I handle the difference result of the two obj comparison? I'm lost in this :(

  • I do not understand what this output is telling us. Here is the demangling of the symbols referred to:

    T1 * <unnamed>::emplace<lom::lb::CounterWrap<lom::lb::CounterCmp<unsigned int, std::greater<unsigned int>>>>(lom::byte_stream &)

    T1 * <unnamed>::emplace<lom::lb::CounterWrap<lom::lb::CounterCmp<unsigned int, std::greater<unsigned int>>>>(lom::byte_stream &)

    It appears that the unnamed classes are given random internal names (de4062607 and 2372d2807).  If so, this is probably a harmless difference.

  • so can I understand I can use link debug options "--no_demangle" to diable these symbols in the linked objects before compare it?

    by compare the link object, with using "--no_demangle", there is other difference, do you have any suggestion? thanks. (BTW, ccs_get_slow_code section is created by developer)

    ======================================================================
    Comparing File Headers : elf32_ehdr
    ======================================================================
             Differences:    DlCpu3.out     DlCpu3.out
                 e_entry:           0x860e52a0               0x860e52c0
    ======================================================================
    Comparing Sections : section = .cinit
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = .cpp_init_array
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = .fastcode
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = .fastconst
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = .pucchFastCode
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = .slowcode
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = .smallPoolAllocator
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = .switch
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = .text : elf32_shdr
    ======================================================================
             Differences:    DlCpu3.out     DlCpu3.out
                 sh_size:              0x71280                  0x712a0
    ======================================================================
    Comparing Sections : section = .vector0
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = .version
    ======================================================================

     Raw data is different
    ======================================================================
    Comparing Sections : section = NonDumpedConsts
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = OseDumpedConsts
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = OseFastCode
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = RtsFastCode
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = ccs_get_slow_code
    ======================================================================
        Raw data is different
    ======================================================================
    Comparing Sections : section = ccs_get_slow_code : elf32_shdr
    ======================================================================
             Differences:    DlCpu3.out     DlCpu3.out
                 sh_addr:           0x86121720               0x86121740

    ......

  • calvin xu said:
    so can I understand I can use link debug options "--no_demangle" to diable these symbols in the linked objects before compare it?

    --no_demangle should not affect the object file.  It should only affect the diagnostic messages printed to the console.

  • Thanks for your answer.

    Do you have suggestion for the linked object compared result?

  • calvin xu said:
    by compare the link object, with using "--no_demangle", there is other difference

    You are saying that merely adding --no_demangle resulted in additional differences?  That does not make sense.  The option --no_demangle only affects diagnostics emitted by the linker, not the binary .out file.

    calvin xu said:
    ======================================================================
    Comparing File Headers : elf32_ehdr
    ======================================================================
             Differences:    DlCpu3.out     DlCpu3.out
                 e_entry:           0x860e52a0               0x860e52c0

    That means the entry point is different.

    calvin xu said:
    ======================================================================
    Comparing Sections : section = .cinit
    ======================================================================
        Raw data is different

    That means the bits loaded to the target (called the raw data) in the section .cinit are different.  This happens with several of the sections.

    calvin xu said:
    ======================================================================
    Comparing Sections : section = .text : elf32_shdr
    ======================================================================
             Differences:    DlCpu3.out     DlCpu3.out
                 sh_size:              0x71280                  0x712a0

    This means the .text section has changed sizes.

    Generally speaking, these two files are quite different.

    Thanks and regards,

    -George