2

I want to verify if an object has been compiled in 32-bit or 64-bit:

% readelf -h my_obj
ELF Header:
  Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  ...

Since ELF32 is displayed, does this guarantee that the object is in 32-bit mode?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mark
  • 6,052
  • 8
  • 61
  • 129

1 Answers1

2

Fat binaries aren't common or standard for ELF, so the class does reliably indicate 32 vs 64 bit. But to figure out whether you're looking at 32-bit x86, ARM, MIPS, or whatever, you have to also inspect the Machine field right below the Type field.

user57368
  • 5,675
  • 28
  • 39