class_docstr: Representation of an ELF executable.
class_docstr_tok: ["Representation","of","an","ELF","executable","."]
code: def __init__(self, f: IO[bytes]) -> None:
      self._f = f
  
      try:
          ident = self._read("16B")
      except struct.error:
          raise ELFInvalid("unable to parse identification")
      magic = bytes(ident[:4])
      if magic != b"\x7fELF":
          raise ELFInvalid(f"invalid magic: {magic!r}")
  
      self.capacity = ident[4]  # Format for program header (bitness).
      self.encoding = ident[5]  # Data structure encoding (endianness).
  
      try:
          # e_fmt: Format for program header.
          # p_fmt: Format for section header.
          # p_idx: Indexes to find p_type, p_offset, and p_filesz.
          e_fmt, self._p_fmt, self._p_idx = {
              (1, 1): (
                  "<HHIIIIIHHH",
                  "<IIIIIIII",
                  (0, 1, 4),
              ),  # 32-bit LSB.
              (1, 2): (
                  ">HHIIIIIHHH",
                  ">IIIIIIII",
                  (0, 1, 4),
              ),  # 32-bit MSB.
              (2, 1): (
                  "<HHIQQQIHHH",
                  "<IIQQQQQQ",
                  (0, 2, 5),
              ),  # 64-bit LSB.
              (2, 2): (
                  ">HHIQQQIHHH",
                  ">IIQQQQQQ",
                  (0, 2, 5),
              ),  # 64-bit MSB.
          }[(self.capacity, self.encoding)]
      except KeyError:
          raise ELFInvalid(
              f"unrecognized capacity ({self.capacity}) or "
              f"encoding ({self.encoding})"
          )
  
      try:
          (
              _,
              self.machine,  # Architecture type.
              _,
              _,
              self._e_phoff,  # Offset of program header.
              _,
              self.flags,  # Processor-specific flags.
              _,
              self._e_phentsize,  # Size of section.
              self._e_phnum,  # Number of sections.
          ) = self._read(e_fmt)
      except struct.error as e:
          raise ELFInvalid(
              "unable to parse machine and section information"
          ) from e
  
file_path: metaflow/metaflow/_vendor/packaging/_elffile.py
imports: import enum
  import os
  import struct
  from typing import IO, Optional, Tuple
label_desc: Use image node_id 1 to create a new ELFFile object  with example: obj = ELFFile(f)