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.

Binary Comparison using objdiff.pl

Hi,

I have rebuild a release package twice using "TMS470 C/C++ CODE GENERATION TOOLS 4.6.3", when i compare the binaries using objdiff.pl, instead of showing it as identical i get following result:

======================================================================
Comparing Sections : section = .const
======================================================================
 Raw data is different
======================================================================
Comparing Sections : section = .strtab
======================================================================
 Raw data is different
======================================================================
Comparing Sections : section = ti.sdo.ipc.SharedRegion_0
======================================================================
 Raw data is different

Files are different

Following is the command i am using for comparison:

perl objdiff.pl binary1 binary1 ofd470.exe

Would like to know why difference is coming even though same tools are used and build is done on same machine.

 

  • I saw a case very similar to this one recently.  I'll tell you what we saw in that case.  You likely have the same issues.

    The objdiff utility is comparing some sections that should not be compared.  One example is .strtab.  A bug has been opened against objdiff for this issue.

    The ti.sdo.ipc.SharedRegion_0 section is not being handled properly in the linker and objdiff.  I filed ClearQuest entry SDSCM00038860.  You can track it with the SDOWP link in my sig below. 

    The difference in the .const section is almost certainly a true difference.  In the other similar case, Codec Engine was being rebuilt each time.  And Codec Engine source code places a string in target memory with a time stamp of when it was built.  

    There is nothing that can done at the tool level about the .const difference.  But for the other differences, tell objdiff to skip sections in the comparison.  Write a configuration file, and supply it on the command line with --config_file=file.  Yours would look like this:

        # Comments look like this
        SKIP_BY_NAME = .strtab
        SKIP_BY_NAME = ti.sdo.ipc.SharedRegion_0
    

    Add other section names as needed.  In general, if sectti (another cg_xml script) doesn't show anything about the section, then you don't need to compare it.  You can read more about it in the cg_xml documentation.  There is a file named index.htm in the root directory of the cg_xml installation.  Load it into your favorite web browser.  Navigate to a address similar to: file:///C:/Program%20Files/Texas%20Instruments/cg_xml/docs/ofd/objdiff.htm#using_the_configuration_file_to_skip_sections .

    Thanks and regards,

    -George 

  • Thanks George, will follow the steps as told by you.

    Regards,

    Ravinder 

  • Hi George,

    I have printed the verbose of .const difference between two binary files ( after skipping .strtab and ti.sdo.ipc.SharedRegion_0 sections ), it is something like this

    ======================================================================
    Comparing Sections : section = .const
    ======================================================================
    Raw data is different
       Byte 628726 is different
          vs2_m3video_whole_program_debug1.xem3: 0x31
          vs2_m3video_whole_program_debug2.xem3: 0x32
       Byte 628727 is different
          vs2_m3video_whole_program_debug1.xem3: 0x39
          vs2_m3video_whole_program_debug2.xem3: 0x30
      

    My question is the byte offset which is printed onto console "628726" (0x997f6) for the difference encountered is correct ?

    I compared it with Hex compare utility and found there are no difference at offset 0x 997F6, where as the timstamp difference is at "0xFCEE3" , the values of bytes which differ are correct.

    Regards,
    Ravinder

  • In ASCII, the two bytes 628726-7 are "19" in debug1, "20" in debug2.  Most likely this is a string representation of time, ultimately from using __TIME__ somewhere in the source code.

  • Hi,

    I know its time representation, my question was why the byte offset shown using objdiff is not correct, i am assuming this offset is from the start of file.

    Regards,

    Ravinder 

  • The offset is probably the offset from the start of the section, which cannot be computed directly from the file position.

  • The byte offset reported by objdiff is from the start of the section.

    -George

  • Hi George,

    The above method of binary comparison works fine if we compare the binaries built on same PC. But if i compare the pre-build binaries which comes as part of release and rebuild binaries build at  my end, i am seeing difference in many sections. Same set of tools are used to build the release at my end and functionality is same.

    Have attached difference and also the binaries which i have compared.

    ======================================================================
    Comparing Sections : section = .const : elf32_shdr
    ======================================================================
             Differences: F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video.xem3	 F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video_whole_program_debug.xem3
                 sh_size:              0x9aefe	              0x9afb6
    ======================================================================
    Comparing Sections : section = .data
    ======================================================================
    	Raw data is different
    ======================================================================
    Comparing Sections : section = .data : elf32_shdr
    ======================================================================
             Differences: F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video.xem3	 F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video_whole_program_debug.xem3
                 sh_addr:           0x8ff93838	           0x8ff938f0
    ======================================================================
    Comparing Sections : section = .dynamic
    ======================================================================
    	Raw data is different
    ======================================================================
    Comparing Sections : section = .dynstr : elf32_shdr
    ======================================================================
             Differences: F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video.xem3	 F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video_whole_program_debug.xem3
                 sh_size:                0x15f	                0x15d
    ======================================================================
    Comparing Sections : section = .dynsym
    ======================================================================
    	Raw data is different
    ======================================================================
    Comparing Sections : section = .resetVecs
    ======================================================================
    	Raw data is different
    ======================================================================
    Comparing Sections : section = .stack : elf32_shdr
    ======================================================================
             Differences: F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video.xem3	 F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video_whole_program_debug.xem3
                 sh_addr:           0x8ffaca1c	           0x8ffacad4
    ======================================================================
    Comparing Sections : section = .symtab
    ======================================================================
    	Raw data is different
    ======================================================================
    Comparing Sections : section = .sysmem : elf32_shdr
    ======================================================================
             Differences: F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video.xem3	 F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video_whole_program_debug.xem3
                 sh_addr:           0x8ffb0820	           0x8ffb08d8
    ======================================================================
    Comparing Sections : section = .taskStackSection : elf32_shdr
    ======================================================================
             Differences: F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video.xem3	 F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video_whole_program_debug.xem3
                 sh_addr:           0x8ffa2a1c	           0x8ffa2ad4
    ======================================================================
    Comparing Sections : section = .text
    ======================================================================
    	Raw data is different
    ======================================================================
    Comparing Sections : section = .vecs
    ======================================================================
    	Raw data is different
    ======================================================================
    Comparing Sections : section = xdc.meta : elf32_shdr
    ======================================================================
             Differences: F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video.xem3	 F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video_whole_program_debug.xem3
                 sh_size:                0x103	                0x101
    ======================================================================
    Comparing Segment Tables : program_table
    ======================================================================
    Only in F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video.xem3
    	p_vaddr = 0x8ff93838, p_type = PT_LOAD
    	
    Only in F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video_whole_program_debug.xem3
    	p_vaddr = 0x8ff938f0, p_type = PT_LOAD
    	
    ======================================================================
    Comparing Segment Tables : program_table : p_vaddr = 0x8fef8938, p_type = PT_LOAD
    ======================================================================
             Differences: F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video.xem3	 F:\SDK_Releases\Binary_Comparison\Jan_12th_2010\vs2_m3video_whole_program_debug.xem3
                 p_memsz:              0x9aefe	              0x9afb6
    
    Files are different
    

    4375.Binaries.zip

    Would like to know why the difference is coming when set of tools used are same.

    Thanks and Regards,

    Ravinder

  • There are a lot of small differences, ultimately coming from a string $C$SL41 at target address 0x8ff8a184 in .const.

    In vs2_m3video.xem3, this string is:

    '    package ti.sdo.ipc.family (D:/AVME4_Tools/ipc_1_22_00_13_eng/packages/ti/sdo/ipc/family/) [1, 0, 0, 0]'

    In vs2_m3video_whole_program_debug.xem3, this string is:

    '    package ti.sdo.ipc.family (F:/Tools/sdk_5008/ipc_1_22_00_13_eng/packages/ti/sdo/ipc/family/) [1, 0, 0, 0]'

  • There are few difference in other sections, can you let me know what is the reason behind them.

    My idea of using this utility was to do Automation. We have to build a release under Linux and Windows. In total we get 8 rebuild binaries, goal  was to execute only pre-build binary and do binary comparison for rest using this utility. Let me know if there is any other utility available which can do this.

     

    Thanks and Regards,

    Ravinder

     

  • A lot of those differences are caused by the change in size of .const due to this string.  Because the size of .const has changed, the starting addresses of .data,  .stack, and .sysmem are moved, and so any pointer into any of those sections will change, which for ARM means the .text section will change.  Section "xdc.meta" is not allocated in target memory and should be ignored for binary comparison.

  • Archaeologist said:

    In vs2_m3video.xem3, this string is:

    '    package ti.sdo.ipc.family (D:/AVME4_Tools/ipc_1_22_00_13_eng/packages/ti/sdo/ipc/family/) [1, 0, 0, 0]'

    In vs2_m3video_whole_program_debug.xem3, this string is:

    '    package ti.sdo.ipc.family (F:/Tools/sdk_5008/ipc_1_22_00_13_eng/packages/ti/sdo/ipc/family/) [1, 0, 0, 0]'

    This difference is likely b/c Codec Engine [by default] adds a full list of all packages and their original locations into the final executable.  The end user can emit this very valuable information via the popular CE_DEBUG feature, and it greatly helps with support as debug logs automatically provide details about what's in the system.

    This particular feature can be disabled, a description for doing so is in this FAQ.  Please think twice before doing this, as the benefit of enabling this automation test may not outweigh the increase in support burden.

    Chris

  • Hi,

    In one of my early queries it was communicated that the utility doesn't work on relative address of section's. But it takes the start address for comparison from start of each section.

    Does it mean i can't use this utility for binary comparison for binaries generated on different PC's with tools placed under different directories.

    Regards,
    Ravinder 

  • Ravinder Singh said:
    Does it mean i can't use this utility for binary comparison for binaries generated on different PC's with tools placed under different directories.

    That is a limitation at present, unless you remove the CE_DEBUG information as described by the FAQ referenced in the post from Chris.  We are considering solutions to this problem.  But any such solution will not be released for quite some time.

    Thanks and regards,

    -George

  • George,

           Is there a Bug (" Size change in one sections causes this tool "objdiff" to interpret other section also different") filed for objdiff utility. Could we please ensure that this issue would be fixed moving forward.

    Best Regards

    Velan

  • When the size of a section changes (presuming this section is loaded to target memory), this causes all sections after it in memory to begin on different addresses.  Further, all symbolic references to these sections are different, which can show up as differences in any section.  It is beyond the capability of objdiff to compensate for such differences.

    Thanks and regards,

    -George