Different section header offsets in otherwise identical object files

59 Views Asked by At

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?

1

There are 1 best solutions below

1
Employed Russian On

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?