0

So I have two different ELF files, one that came precompiled and the other I compiled from source. The output from readelf is:

Precompiled File (File1):

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           Texas Instruments TMS320C6000 DSP family
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          22752 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         0
  Size of section headers:           40 (bytes)
  Number of section headers:         83
  Section header string table index: 72
There are 83 section headers, starting at offset 0x58e0:

Compiled From Source File (File2):

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           Texas Instruments TMS320C6000 DSP family
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          22920 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         0
  Size of section headers:           40 (bytes)
  Number of section headers:         83
  Section header string table index: 72
There are 83 section headers, starting at offset 0x5988:

Questions:

What would cause this difference in the section header offset from 22752 to 22920, when everything else is the same?

The rest of the file is exactly the same (save the offsets), so I compiled the file correctly...but why this difference in the section header offset?

The Dude
  • 661
  • 2
  • 11
  • 20

1 Answers1

0

What would cause this difference in the section header offset from 22752 to 22920, when everything else is the same?

Different compiler or assembler could cause this.

The rest of the file is exactly the same

How do you know that?

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • Well, I suppose I don't know that for sure but I checked this: 1. Diff'd the file and the only difference is the offset of the addresses 2. Checked the symbol table and they are the same 3. The header is the same outside of the offset 4. The file that gets generated from my -preproc_with_compile option is the same as the corresponding one from the prebuilt. 5. The difference in the compiled file size is exactly the same as the difference in the section offset. Is that enough? @Employed Russian? Or is there something else I should be checking? – The Dude Aug 19 '22 at 12:28