///|
/// Errors raised while turning an ELF file into a link input.
pub(all) suberror LinkError {
  InvalidElf(String)
  UnsupportedObjectType(UInt32)
  UnsupportedClass
  UnsupportedMachine
  MissingSymbolTable
  InvalidRelocation(String)
}

///|
/// A short, stable description of a link-input error.
pub fn LinkError::message(self : LinkError) -> String {
  match self {
    InvalidElf(reason) => "invalid ELF input: \{reason}"
    UnsupportedObjectType(kind) =>
      "object type \{kind} is not a relocatable ET_REL object"
    UnsupportedClass => "only ELF64 objects are accepted"
    UnsupportedMachine => "only x86-64 and AArch64 objects are accepted"
    MissingSymbolTable => "object has relocations but no symbol table"
    InvalidRelocation(section) =>
      "relocation section '\{section}' contains an invalid entry"
  }
}