Switch to use elfclass over relawidth

This commit is contained in:
Joe Hendrix 2017-06-14 16:49:09 -07:00
parent 45b5c181e3
commit e09e37fab4
No known key found for this signature in database
GPG Key ID: 00F67DE32381DB9F

View File

@ -184,10 +184,6 @@ mlsMemory = lens _mlsMemory (\s v -> s { _mlsMemory = v })
mlsIndexMap :: Simple Lens (MemLoaderState w) (SectionIndexMap w) mlsIndexMap :: Simple Lens (MemLoaderState w) (SectionIndexMap w)
mlsIndexMap = lens _mlsIndexMap (\s v -> s { _mlsIndexMap = v }) mlsIndexMap = lens _mlsIndexMap (\s v -> s { _mlsIndexMap = v })
relaWidthOfAddr :: AddrWidthRepr w -> RelaWidth w
relaWidthOfAddr Addr32 = Rela32
relaWidthOfAddr Addr64 = Rela64
initState :: forall w . AddrWidthRepr w -> MemLoaderState w initState :: forall w . AddrWidthRepr w -> MemLoaderState w
initState w = MLS { _mlsIndex = 0 initState w = MLS { _mlsIndex = 0
, _mlsMemory = emptyMemory w , _mlsMemory = emptyMemory w
@ -290,16 +286,16 @@ mkSymbolRef (sym, mverId) =
-- | Creates a relocation map from the contents of a dynamic section. -- | Creates a relocation map from the contents of a dynamic section.
relocMapOfDynamic :: ElfData relocMapOfDynamic :: ElfData
-> RelaWidth w -> ElfClass w
-> ElfMachine -> ElfMachine
-> VirtAddrMap w -> VirtAddrMap w
-> L.ByteString -- ^ Contents of .dynamic section -> L.ByteString -- ^ Contents of .dynamic section
-> MemLoader w (RelocMap (MemWord w)) -> MemLoader w (RelocMap (MemWord w))
relocMapOfDynamic d w mach virtMap dynContents = relocMapOfDynamic d cl mach virtMap dynContents =
case (w, mach) of case (cl, mach) of
(Rela64, EM_X86_64) -> do (ELFCLASS64, EM_X86_64) -> do
dynSection <- either (throwError . show) pure $ dynSection <- either (throwError . show) pure $
dynamicEntries d (relaClass w) virtMap dynContents dynamicEntries d cl virtMap dynContents
relocs <- either (throwError . show) pure $ relocs <- either (throwError . show) pure $
dynRelocations (dynSection :: DynamicSection X86_64_RelocationType) dynRelocations (dynSection :: DynamicSection X86_64_RelocationType)
syms <- either (throwError . show) pure $ syms <- either (throwError . show) pure $
@ -373,7 +369,7 @@ memoryForElfSegments opt e = do
[] -> pure Map.empty [] -> pure Map.empty
[dynPhdr] -> [dynPhdr] ->
let dynContents = sliceL (phdrFileRange dynPhdr) contents let dynContents = sliceL (phdrFileRange dynPhdr) contents
in relocMapOfDynamic d (relaWidthOfAddr w) (elfMachine e) virtMap dynContents in relocMapOfDynamic d (elfClass e) (elfMachine e) virtMap dynContents
_ -> throwError "Multiple dynamic sections" _ -> throwError "Multiple dynamic sections"
let intervals :: ElfFileSectionMap (ElfWordType w) let intervals :: ElfFileSectionMap (ElfWordType w)