From 36c3861a79e61aebc665dae14b896c03b8a8db69 Mon Sep 17 00:00:00 2001 From: Valentin Robert Date: Mon, 15 Jan 2024 11:24:13 -0800 Subject: [PATCH] remove seemingly unnecessary TemplateHaskell --- src/Data/ElfEdit.hs | 2 +- src/Data/ElfEdit/HighLevel/Get.hs | 14 +------------- src/Data/ElfEdit/HighLevel/Layout.hs | 12 +----------- src/Data/ElfEdit/HighLevel/Types.hs | 8 +------- 4 files changed, 4 insertions(+), 32 deletions(-) diff --git a/src/Data/ElfEdit.hs b/src/Data/ElfEdit.hs index 3935f95..1cfff4c 100644 --- a/src/Data/ElfEdit.hs +++ b/src/Data/ElfEdit.hs @@ -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 diff --git a/src/Data/ElfEdit/HighLevel/Get.hs b/src/Data/ElfEdit/HighLevel/Get.hs index 4a81f5e..5eed738 100644 --- a/src/Data/ElfEdit/HighLevel/Get.hs +++ b/src/Data/ElfEdit/HighLevel/Get.hs @@ -4,8 +4,8 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} + module Data.ElfEdit.HighLevel.Get ( -- Elf parsing getElf @@ -161,8 +161,6 @@ phdrSegment phdr regions = , elfSegmentData = regions } -$(pure []) - ------------------------------------------------------------------------ -- GetResult @@ -180,8 +178,6 @@ errorPair c = warn :: ElfParseError -> GetResult () warn e = seq e $ GetResult $ MTL.modify' $ (e:) -$(pure []) - ------------------------------------------------------------------------ -- CollectedRegion @@ -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 @@ -414,8 +408,6 @@ mkSequence contents (CRL l) = do let sr = SizedRegions Seq.empty 0 sizedRegions <$> mkSequence' contents sr 0 l -$(pure []) - ------------------------------------------------------------------------ -- Relro handling @@ -435,8 +427,6 @@ asRelroRegion segMap phdr = do , relroSize = phdrFileSize phdr } -$(pure []) - -------------------------------------------------------------------------------- -- getElf @@ -588,8 +578,6 @@ getElf ehi = elfClassInstances (headerClass (header ehi)) $ errorPair $ do , elfGnuRelroRegions = relroRegions } -$(pure []) - -------------------------------------------------------------------------------- -- parseElf diff --git a/src/Data/ElfEdit/HighLevel/Layout.hs b/src/Data/ElfEdit/HighLevel/Layout.hs index 60a4d12..1dd369b 100644 --- a/src/Data/ElfEdit/HighLevel/Layout.hs +++ b/src/Data/ElfEdit/HighLevel/Layout.hs @@ -3,8 +3,8 @@ {-# LANGUAGE PatternGuards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} -{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -Wwarn #-} + module Data.ElfEdit.HighLevel.Layout ( renderElf , elfSections @@ -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 @@ -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)) @@ -101,8 +97,6 @@ elfSectionNames e = concatMap regionNames (toList (e^.elfFileData)) regionNames (ElfDataSection s) = [elfSectionName s] regionNames _ = [] -$(pure []) - ------------------------------------------------------------------------ -- elfSectionAsGOT @@ -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 diff --git a/src/Data/ElfEdit/HighLevel/Types.hs b/src/Data/ElfEdit/HighLevel/Types.hs index 0847df8..ea72c28 100644 --- a/src/Data/ElfEdit/HighLevel/Types.hs +++ b/src/Data/ElfEdit/HighLevel/Types.hs @@ -3,8 +3,8 @@ {-# LANGUAGE KindSignatures #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE UndecidableInstances #-} + module Data.ElfEdit.HighLevel.Types ( -- * Top level declarations Elf(..) @@ -87,8 +87,6 @@ symtabSize c symtab = elfClassInstances c $ in fromIntegral (symtabEntrySize c) * cnt -} -$(pure []) - ------------------------------------------------------------------------ -- ElfSegment and ElfDataRegion @@ -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 @@ -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