{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}

module GHC.Toolchain.Tools.Readelf (Readelf(..), findReadelf) where

import Control.Monad

import GHC.Toolchain.Prelude
import GHC.Toolchain.Program

newtype Readelf = Readelf { Readelf -> Program
readelfProgram :: Program
                          }
    deriving (Int -> Readelf -> ShowS
[Readelf] -> ShowS
Readelf -> String
(Int -> Readelf -> ShowS)
-> (Readelf -> String) -> ([Readelf] -> ShowS) -> Show Readelf
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Readelf -> ShowS
showsPrec :: Int -> Readelf -> ShowS
$cshow :: Readelf -> String
show :: Readelf -> String
$cshowList :: [Readelf] -> ShowS
showList :: [Readelf] -> ShowS
Show, ReadPrec [Readelf]
ReadPrec Readelf
Int -> ReadS Readelf
ReadS [Readelf]
(Int -> ReadS Readelf)
-> ReadS [Readelf]
-> ReadPrec Readelf
-> ReadPrec [Readelf]
-> Read Readelf
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Readelf
readsPrec :: Int -> ReadS Readelf
$creadList :: ReadS [Readelf]
readList :: ReadS [Readelf]
$creadPrec :: ReadPrec Readelf
readPrec :: ReadPrec Readelf
$creadListPrec :: ReadPrec [Readelf]
readListPrec :: ReadPrec [Readelf]
Read)

-- | Readelf is only needed by 'GHC.Toolchain.Tools.Link.checkBfdCopyBug'.
findReadelf :: ProgOpt -> M Readelf
findReadelf :: ProgOpt -> M Readelf
findReadelf ProgOpt
progOpt = String -> M Readelf -> M Readelf
forall a. Show a => String -> M a -> M a
checking String
"for 'readelf'" (M Readelf -> M Readelf) -> M Readelf -> M Readelf
forall a b. (a -> b) -> a -> b
$ do
    readelfProgram <- String -> ProgOpt -> [String] -> M Program
findProgram String
"readelf utility" ProgOpt
progOpt [String
"readelf"]
    return Readelf {..}