Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround for IntervalMap empty intersections #317

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion base/src/Data/Macaw/Memory/ElfLoader.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import qualified Data.ElfEdit.Prim as Elf
import Data.Foldable
import Data.IntervalMap.Strict (Interval(..), IntervalMap)
import qualified Data.IntervalMap.Strict as IMap
import qualified Data.IntervalMap.Generic.Strict as IMap
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe
Expand Down Expand Up @@ -1179,7 +1180,10 @@ insertElfSegment regIdx addrOff shdrMap contents relocMap phdr = do
-- Add segment index to address mapping to memory object.
mlsMemory %= memBindSegmentIndex segIdx seg
-- Iterative through sections
let l = IMap.toList $ IMap.intersecting shdrMap (IntervalCO phdrOffset phdrEnd)
let interval = IntervalCO phdrOffset phdrEnd
-- Workaround for https://github.com/bokesan/IntervalMap/issues/9, where 'IMap.intersecting' can return
-- nonempty results when given an empty interval.
let l = if IMap.isEmpty interval then [] else IMap.toList $ IMap.intersecting shdrMap interval
forM_ l $ \(i, elfIdx) -> do
case i of
IntervalCO shdr_start _ -> do
Expand Down