Skip to content

Commit

Permalink
Merge pull request #42 from GaloisInc/vr/remove-template-haskell
Browse files Browse the repository at this point in the history
remove seemingly unnecessary TemplateHaskell
  • Loading branch information
Ptival authored Jan 18, 2024
2 parents fa665fa + 36c3861 commit 3679829
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/Data/ElfEdit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ and the operations on the 'Elf' datatype. To generate an Elf file from
The low level interface is described in 'Data.ElfEdit.Prim'.
-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeFamilies #-}

module Data.ElfEdit
( -- * High-level Elf type
-- ** Main type
Expand Down
14 changes: 1 addition & 13 deletions src/Data/ElfEdit/HighLevel/Get.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}

module Data.ElfEdit.HighLevel.Get
( -- Elf parsing
getElf
Expand Down Expand Up @@ -161,8 +161,6 @@ phdrSegment phdr regions =
, elfSegmentData = regions
}

$(pure [])

------------------------------------------------------------------------
-- GetResult

Expand All @@ -180,8 +178,6 @@ errorPair c =
warn :: ElfParseError -> GetResult ()
warn e = seq e $ GetResult $ MTL.modify' $ (e:)

$(pure [])

------------------------------------------------------------------------
-- CollectedRegion

Expand Down Expand Up @@ -275,8 +271,6 @@ insertSegment :: Integral (ElfWordType w)
-> CollectedRegionList w
insertSegment = insertSegment' []

$(pure [])

insertNewRegion' :: (Ord (ElfWordType w), Num (ElfWordType w))
=> [CollectedRegion w] -- ^ Processed regions in reverse order
-> B.ByteString -- ^ Name of this region
Expand Down Expand Up @@ -414,8 +408,6 @@ mkSequence contents (CRL l) = do
let sr = SizedRegions Seq.empty 0
sizedRegions <$> mkSequence' contents sr 0 l

$(pure [])

------------------------------------------------------------------------
-- Relro handling

Expand All @@ -435,8 +427,6 @@ asRelroRegion segMap phdr = do
, relroSize = phdrFileSize phdr
}

$(pure [])

--------------------------------------------------------------------------------
-- getElf

Expand Down Expand Up @@ -588,8 +578,6 @@ getElf ehi = elfClassInstances (headerClass (header ehi)) $ errorPair $ do
, elfGnuRelroRegions = relroRegions
}

$(pure [])

--------------------------------------------------------------------------------
-- parseElf

Expand Down
12 changes: 1 addition & 11 deletions src/Data/ElfEdit/HighLevel/Layout.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -Wwarn #-}

module Data.ElfEdit.HighLevel.Layout
( renderElf
, elfSections
Expand Down Expand Up @@ -43,8 +43,6 @@ updateSeq f l0 =
where compose Nothing r = r
compose (Just e) r = e Seq.<| r

$(pure [])

-- | Traverse segments in an ELF file and modify or delete them
updateSegments :: forall w f
. Monad f
Expand Down Expand Up @@ -86,8 +84,6 @@ traverseElfDataRegions :: Monad f
-> f (Elf w)
traverseElfDataRegions f = updateDataRegions (fmap Just . f)

$(pure [])

-- | Return name of all elf sections.
elfSectionNames :: forall w . Elf w -> [B.ByteString]
elfSectionNames e = concatMap regionNames (toList (e^.elfFileData))
Expand All @@ -101,8 +97,6 @@ elfSectionNames e = concatMap regionNames (toList (e^.elfFileData))
regionNames (ElfDataSection s) = [elfSectionName s]
regionNames _ = []

$(pure [])

------------------------------------------------------------------------
-- elfSectionAsGOT

Expand Down Expand Up @@ -163,14 +157,10 @@ updateSections fn0 e0 = elfClassInstances (elfClass e0) $ elfFileData (updateSeq
impl fn (ElfDataSection s) = fmap norm <$> fn s
impl _ d = pure (Just d)

$(pure [])

-- | Traverse elf sections
elfSections :: Simple Traversal (Elf w) (ElfSection (ElfWordType w))
elfSections f = updateSections (fmap Just . f)

$(pure [])

------------------------------------------------------------------------
-- Utilities

Expand Down
8 changes: 1 addition & 7 deletions src/Data/ElfEdit/HighLevel/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}

module Data.ElfEdit.HighLevel.Types
( -- * Top level declarations
Elf(..)
Expand Down Expand Up @@ -87,8 +87,6 @@ symtabSize c symtab = elfClassInstances c $
in fromIntegral (symtabEntrySize c) * cnt
-}

$(pure [])

------------------------------------------------------------------------
-- ElfSegment and ElfDataRegion

Expand Down Expand Up @@ -183,8 +181,6 @@ data ElfDataRegion w
| ElfDataRaw B.ByteString
-- ^ Identifies an uninterpreted array of bytes.

$(pure [])

ppSegment :: ElfWidthConstraints w => ElfSegment w -> Doc ann
ppSegment s =
vcat
Expand Down Expand Up @@ -217,8 +213,6 @@ ppRegion r = case r of
ElfDataSection sec -> "other section:" <+> ppShow sec
ElfDataRaw bs -> "raw bytes:" <+> ppShow bs

$(pure [])

-- | This applies a function to each data region in an elf file, returning
-- the sum using 'Alternative' operations for combining results.
asumDataRegions :: Alternative f => (ElfDataRegion w -> f a) -> Elf w -> f a
Expand Down

0 comments on commit 3679829

Please sign in to comment.