mirror of
https://github.com/GaloisInc/macaw.git
synced 2024-11-23 16:35:02 +03:00
Update dwarf parsing to increase laziness and robustness.
This commit is contained in:
parent
c9218a9284
commit
cbd16ed481
@ -1,5 +1,5 @@
|
||||
name: macaw-base
|
||||
version: 0.3.15.1
|
||||
version: 0.3.15.2
|
||||
author: Galois, Inc.
|
||||
maintainer: jhendrix@galois.com
|
||||
build-type: Simple
|
||||
@ -34,12 +34,8 @@ library
|
||||
binary-symbols >= 0.1.3,
|
||||
bytestring,
|
||||
containers >= 0.5.8.1,
|
||||
<<<<<<< HEAD
|
||||
elf-edit >= 0.35,
|
||||
=======
|
||||
elf-edit >= 0.37,
|
||||
>>>>>>> Update elf-edit; export additional capabilities for Reopt.
|
||||
galois-dwarf,
|
||||
elf-edit >= 0.38,
|
||||
galois-dwarf >= 0.2.2,
|
||||
IntervalMap >= 0.5,
|
||||
lens >= 4.7,
|
||||
mtl,
|
||||
|
@ -478,7 +478,6 @@ ppApp pp a0 = runIdentity $ ppAppA (Identity . pp) a0
|
||||
instance HasRepr (App f) TypeRepr where
|
||||
typeRepr a =
|
||||
case a of
|
||||
MkTuple fieldTypes _ -> TupleTypeRepr fieldTypes
|
||||
Eq _ _ -> knownRepr
|
||||
Mux tp _ _ _ -> tp
|
||||
MkTuple fieldTypes _ -> TupleTypeRepr fieldTypes
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1301,20 +1301,30 @@ insertAllocatedSection hdr symtab sectionMap regIdx nm = do
|
||||
memoryForElfSections :: forall w
|
||||
. Elf w
|
||||
-> Either String (Memory w, SectionIndexMap w, [MemLoadWarning])
|
||||
memoryForElfSections e =
|
||||
runMemLoader (toEndianness (Elf.elfData e)) (emptyMemory (elfAddrWidth (elfClass e))) $ do
|
||||
let hdr = Elf.elfHeader e
|
||||
-- Create map from section name to sections with that name.
|
||||
let sectionMap :: SectionNameMap w
|
||||
sectionMap = foldlOf elfSections insSec Map.empty e
|
||||
where insSec m sec = Map.insertWith (\new old -> old ++ new) (elfSectionName sec) [sec] m
|
||||
|
||||
-- Parse Elf symbol table
|
||||
let symtab =
|
||||
case Elf.elfSymtab e of
|
||||
[] -> NoSymbolTable
|
||||
symTab:_rest -> StaticSymbolTable (Elf.elfSymbolTableEntries symTab)
|
||||
memoryForElfSections e = do
|
||||
let hdr = Elf.elfHeader e
|
||||
-- Create map from section name to sections with that name.
|
||||
let sectionMap :: SectionNameMap w
|
||||
sectionMap = foldlOf elfSections insSec Map.empty e
|
||||
where insSec m sec = Map.insertWith (\new old -> old ++ new) (elfSectionName sec) [sec] m
|
||||
-- Parse Elf symbol table
|
||||
let symtab =
|
||||
case Elf.elfSymtab e of
|
||||
[] -> NoSymbolTable
|
||||
symTab:_rest -> StaticSymbolTable (Elf.elfSymbolTableEntries symTab)
|
||||
memoryForElfSections' hdr sectionMap symtab
|
||||
|
||||
-- | Load allocated Elf sections into memory.
|
||||
--
|
||||
-- This is only used for object files. This version uses low-level types
|
||||
-- for less complex parsing.
|
||||
memoryForElfSections' :: forall w
|
||||
. Elf.ElfHeader w -- ^ Header for elf
|
||||
-> SectionNameMap w -- ^ Map from section name to contents.
|
||||
-> SymbolTable w -- ^ Symbol table for names.
|
||||
-> Either String (Memory w, SectionIndexMap w, [MemLoadWarning])
|
||||
memoryForElfSections' hdr sectionMap symtab =
|
||||
runMemLoader (toEndianness (Elf.headerData hdr)) (emptyMemory (elfAddrWidth (Elf.headerClass hdr))) $ do
|
||||
-- Insert sections
|
||||
forM_ (zip [1..] allocatedSectionInfo) $ \(idx, (nm,_)) -> do
|
||||
insertAllocatedSection hdr symtab sectionMap idx nm
|
||||
|
Loading…
Reference in New Issue
Block a user