{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Data.Elf.Constants.Data where import Data.Binary import Data.Binary.Put import Data.Binary.Get import Data.Bits import Data.Elf.Constants.TH import Data.Endian {- $docs Constants defined here are declared using Template Haskell, so the full documentation is supported only starting from GHC 2.4.x. For the older versions see the sources or the documents describing ELF file format. Data types, patterns and instances are generated by @mkDeclarations@ TH macros. Below is an example of how it works. The code @ $(mkDeclarations BaseWord16 \"TypeName\" \"ValuePrefix\" [ (\"_A\", 0, "Doc strig for ValuePrefix_A") , (\"_B\", 1, "Doc strig for ValuePrefix_B") ]) @ produces this: @ newtype TypeName = TypeName Word16 deriving (Eq, Ord, Enum, Num, Real, Integral, Bits, FiniteBits) instance Show TypeName where show (TypeName 0) = (\"ValuePrefix\" ++ "_A") show (TypeName 1) = (\"ValuePrefix\" ++ "_B") show (TypeName n_a5QI) = (\"TypeName\" ++ (\" \" ++ show n_a5QI)) pattern ValuePrefix_A :: TypeName pattern ValuePrefix_A = TypeName 0 pattern ValuePrefix_B :: TypeName pattern ValuePrefix_B = TypeName 1 instance Binary (Le TypeName) where get = (Le \<$\> (TypeName \<$\> getWord16le)) put (Le (TypeName n_a5QK)) = putWord16le n_a5QK instance Binary (Be TypeName) where get = (Be \<$\> (TypeName \<$\> getWord16be)) put (Be (TypeName n_a5QL)) = putWord16be n_a5QL @ -} -- | Operating system and ABI for which the object is prepared $(mkDeclarations BaseWord8 "ElfOSABI" "ELFOSABI" [ ("_SYSV", 0, "No extensions or unspecified") , ("_HPUX", 1, "Hewlett-Packard HP-UX") , ("_NETBSD", 2, "NetBSD") , ("_LINUX", 3, "Linux") , ("_SOLARIS", 6, "Sun Solaris") , ("_AIX", 7, "AIX") , ("_IRIX", 8, "IRIX") , ("_FREEBSD", 9, "FreeBSD") , ("_TRU64", 10, "Compaq TRU64 UNIX") , ("_MODESTO", 11, "Novell Modesto") , ("_OPENBSD", 12, "Open BSD") , ("_OPENVMS", 13, "Open VMS") , ("_NSK", 14, "Hewlett-Packard Non-Stop Kernel") , ("_AROS", 15, "Amiga Research OS") , ("_ARM", 97, "ARM") , ("_STANDALONE", 255, "Standalone (embedded) application") ]) -- | Object file type $(mkDeclarations BaseWord16 "ElfType" "ET" [ ("_NONE", 0, "Unspecified type") , ("_REL", 1, "Relocatable object file") , ("_EXEC", 2, "Executable object file") , ("_DYN", 3, "Shared object file") , ("_CORE", 4, "Core dump object file") ]) -- | Target architecture $