diff --git a/src/HiFileParser.hs b/src/HiFileParser.hs index 3619939..a15b163 100644 --- a/src/HiFileParser.hs +++ b/src/HiFileParser.hs @@ -67,6 +67,7 @@ data IfaceVersion | V9041 | V9045 | V9081 + | V9120 deriving (Show,Eq,Ord,Enum) -- careful, the Ord matters! @@ -645,6 +646,12 @@ getInterfaceRecent version d = do getInterface :: Get Interface getInterface = do let enableLEB128 = modify (\c -> c { useLEB128 = True}) + -- read a relative bin pointer + let getRelPtr = do + c <- bytesRead + p <- getPtr + pure (fromIntegral c + p) + magic <- lookAhead getWord32be >>= \case -- normal magic @@ -679,6 +686,7 @@ getInterface = do traceGet ("Version: " ++ version) let !ifaceVersion + | version >= "9120" = V9120 | version >= "9081" = V9081 | version >= "9045" = V9045 | version >= "9041" = V9041 @@ -705,7 +713,9 @@ getInterface = do when (ifaceVersion >= V9001) $ void getPtr -- dict_ptr - dictPtr <- getPtr + dictPtr <- if ifaceVersion >= V9120 -- 9.12 uses relative pointers + then getRelPtr + else getPtr traceGet ("Dict ptr: " ++ show dictPtr) -- dict @@ -714,7 +724,12 @@ getInterface = do -- symtable_ptr void getPtr + -- IfaceType table + when (ifaceVersion >= V9120) $ + void getPtr + case ifaceVersion of + V9120 -> getInterfaceRecent ifaceVersion dict V9081 -> getInterfaceRecent ifaceVersion dict V9045 -> getInterfaceRecent ifaceVersion dict V9041 -> getInterfaceRecent ifaceVersion dict diff --git a/test-files/iface/x64/ghc9120/Main.hi b/test-files/iface/x64/ghc9120/Main.hi new file mode 100644 index 0000000..9ee7767 Binary files /dev/null and b/test-files/iface/x64/ghc9120/Main.hi differ diff --git a/test-files/iface/x64/ghc9120/X.hi b/test-files/iface/x64/ghc9120/X.hi new file mode 100644 index 0000000..8d229f7 Binary files /dev/null and b/test-files/iface/x64/ghc9120/X.hi differ diff --git a/test/HiFileParserSpec.hs b/test/HiFileParserSpec.hs index 83569af..91ba74c 100644 --- a/test/HiFileParserSpec.hs +++ b/test/HiFileParserSpec.hs @@ -35,6 +35,7 @@ versions64 = , "ghc9047" -- Last in GHC 9.4 series, using GHC 9.4.5 format , "ghc9063" -- Last in GHC 9.6 series, using GHC 9.4.5 format , "ghc9081" -- First in GHC 9.8 series, using GHC 9.8.1 format + , "ghc9120" -- First in GHC 9.12 series, using GHC 9.12 format ] spec :: Spec