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.

"out of memory" when running objdiff on two elf files

objdiff.exe file1.out file2.out -- ofd6x --xml_indent=0 --obj_display=norawdata,nosymbols,nostrings,norelocs,nolnnos

When running the above, I get this :

Processing file1.out ...
Processing file2.out ...
Comparing files ...

Out of memory!

 

The two elf files are about 29MB each.

Any clue why?

 

 

  • objdiff is written in Perl, and converted to a standalone Windows executable.  The out of memory diagnostic does not come from objdiff itself, but from somewhere deep in the Perl internals.  The most likely explanation is that the process really ran out of memory.

    Try creating the XML in a separate step ...

    % ofd6x -x --xml_indent=0 --obj_display=norawdata,nosymbols,nostrings,norelocs,nolnnos file1.out > file1.xml
    % ofd6x -x --xml_indent=0 --obj_display=norawdata,nosymbols,nostrings,norelocs,nolnnos file2.out > file2.xml
    % objdiff file1.xml file2.xml

    If that doesn't help, then you will have to run the script from Perl directly.  Install 64-bit Perl from http://www.activestate.com/ .  Then invoke objdiff like this ...

    perl objdiff.pl file1.xml file2.xml

    Thanks and regards,

    -George

  • Thank George for the prompt response.... Installing 64-bit perl helped!

    The two elf files are generated off same code base (in different workspaces ) but I see significant differences in all the section specially section address and offset and raw data(see below). What could cause this difference ?


    Processing file1.out ...
    Processing file2.out ...
    Comparing files ...

    ======================================================================
    Comparing File Headers : elf32_ehdr
    ======================================================================
    Differences: file1.out file2.out
    e_entry: 0x821bdbe0 0x821bdbc0
    ======================================================================
    Comparing Sections : section = .cinit : elf32_shdr
    ======================================================================
    Differences: file1.out file2.out
    sh_addr: 0x822387f8 0x822387d8
    sh_size: 0x252c 0x25ac
    ======================================================================
    Comparing Sections : section = .const
    ======================================================================
    Raw data is different
    ======================================================================
    Comparing Sections : section = .const : elf32_shdr
    ======================================================================
    Differences: file1.out file2.out
    sh_addr: 0x821dbbe0 0x821dbbc0
    ======================================================================
    Comparing Sections : section = .init_array
    ======================================================================
    Raw data is different
    ======================================================================
    Comparing Sections : section = .init_array : elf32_shdr
    ======================================================================
    Differences: file1.out file2.out
    sh_addr: 0x822387c8 0x822387a8
    ======================================================================
    Comparing Sections : section = .switch.1
    ======================================================================
    Raw data is different
    ======================================================================
    Comparing Sections : section = .switch.1 : elf32_shdr
    ======================================================================
    Differences: file1.out file2.out
    sh_addr: 0x82215f6c 0x82215f4c
    ======================================================================
    Comparing Sections : section = .switch.2
    ======================================================================
    Raw data is different
    ======================================================================
    Comparing Sections : section = .switch.2 : elf32_shdr
    ======================================================================
    Differences: file1.out file2.out
    sh_addr: 0x82237e40 0x82237e20
    ======================================================================
    Comparing Sections : section = .text : elf32_shdr
    ======================================================================
    Differences: file1.out file2.out
    sh_size: 0x1dbbe0 0x1dbbc0
    ======================================================================
    Comparing Sections : section = .vecs
    ======================================================================
    Raw data is different
    ======================================================================
    Comparing Sections : section = JPEGIDEC_TI_cSect
    ======================================================================
    Raw data is different
    ======================================================================
    Comparing Sections : section = JPEGIDEC_TI_cSect : elf32_shdr
    ======================================================================
    Differences: file1.out file2.out
    sh_addr: 0x82215f80 0x82215f60
    ======================================================================
    Comparing Sections : section = JPEGIENC_TI_cSect1
    ======================================================================
    Raw data is different
    ======================================================================
    Comparing Sections : section = JPEGIENC_TI_cSect1 : elf32_shdr
    ======================================================================
    Differences: file1.out file2.out
    sh_addr: 0x822306a0 0x82230680
    ======================================================================
    Comparing Sections : section = JPEGIENC_TI_cSect2
    ======================================================================
    Raw data is different
    ======================================================================
    Comparing Sections : section = JPEGIENC_TI_cSect2 : elf32_shdr
    ======================================================================
    Differences: file1.out file2.out
    sh_addr: 0x82235400 0x822353e0
    ======================================================================
    Comparing Sections : section = ti.sdo.ipc.SharedRegion_0
    ======================================================================
    Raw data is different
    ======================================================================
    Comparing Sections : section = ti.sdo.ipc.SharedRegion_1
    ======================================================================
    Raw data is different
    ======================================================================
    Comparing Sections : section = ti.sdo.ipc.SharedRegion_2
    ======================================================================
    Raw data is different
    ======================================================================
    Comparing Segment Tables : program_table
    ======================================================================
    Only in file1.out
    p_vaddr = 0x82215f6c, p_type = PT_LOAD
    p_vaddr = 0x82215f80, p_type = PT_LOAD

    Only in file2.out
    p_vaddr = 0x82215f60, p_type = PT_LOAD
    p_vaddr = 0x82215f4c, p_type = PT_LOAD

    ======================================================================
    Comparing Segment Tables : program_table : p_vaddr = 0x82000000, p_type = PT_LOAD
    ======================================================================
    Differences: file1.out file2.out
    p_memsz: 0x215f6a 0x215f4a

    Files are different
  • That's a lot of differences.  Here is a technique that tells you where to focus your effort.  

    Adapt the technique presented in this wiki article.  Except you are not interested in how much the code size increased.  Rather, you are interested in finding any function which changed size at all.  And the functions which changed size the most are the ones to investigate.

    Thanks and regards,

    -George

  • Hi George,

    Based on a cursory look, I can't tell if there's anything in the functions definitions that would cause the compiler to generate different results. However, every time code is compiled(and linked), functions that differ in size vary from build to build. I am using O3 optimization level and wondering if that changes the function size since the code is optimized at the file level (so function size is not guaranteed ?)
  • Smriti Verma said:
    every time code is compiled(and linked), functions that differ in size vary from build to build

    Even with -o3, the same build should generate the same results every time.  And thus the comparison between two builds from different workspaces should show the same differences each time.  If you are not seeing this, then something very strange is occurring.  I cannot even guess what might be wrong.  I recommend you focus on just one function, and work out why it is not building the same every time.  If you suspect something odd is happening during preprocessing, consider using the build option --gen_acp_raw to find the problem.

    Thanks and regards,

    -George

  • The preprocessor output is the same. However, the optimization information file (generated using gen_opt_info), has different memory accesses and dependence:

    "There are xx memory accesses with xx dependences"