From 9d0affba4f9c5e5c1001b69f11df2763cc3039a2 Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Mon, 21 Oct 2024 12:24:03 +0200 Subject: [PATCH] Support 9.12 interface files --- src/HiFileParser.hs | 17 ++++++++++++++++- test-files/iface/x64/ghc9120/Main.hi | Bin 0 -> 2131 bytes test-files/iface/x64/ghc9120/X.hi | Bin 0 -> 736 bytes test/HiFileParserSpec.hs | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test-files/iface/x64/ghc9120/Main.hi create mode 100644 test-files/iface/x64/ghc9120/X.hi 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 0000000000000000000000000000000000000000..9ee7767752a73983e14d23c64192a4ea7ebdb1ec GIT binary patch literal 2131 zcmcgsdrVVT7(b_vD{Q`1tgY>973WEe4v*|M0@Ug>r1ZFBFfqx-8O z1>_MBG*b+NIZIWLLK(!)4$u-Pg5V2~Sp}7cND-)5P(XHW5k}+o=R7y}+??N{(*o*nSiI{wV5wDq>aa$9VEfh%!z?Xx>g?&kKA8?WH`q3Em|C!7QA@K%Mf zHuhAGeNB2oo&EH6Q|>4{a=E0hrTAB8I_xiPd=-O3z<&%>dX;fXxEfY=F%H*j#|k1K4{2 zn-8!B09y#KMF3k2umF@u{A@(B#M+VH`naae?VpzN@OttwQ_o41A)-#K)^|TKW_#BC ze5u)S)l!tcj1w=l+-u0Ond+TR*wrvxP~mBE<$Cqs9~n7&_+e5;cQ&jT%C#33pD8-! z1p-Xhy7Kx{F2`JkCSzsiqwbdtdl8dhS+vt??r9u4!nU8UyWc(9SMdpeJaE;Tb?oW$ zrs`F__V&T2(JAp^@Q+8gAG8mS7~$QTs$N4?xp{;m2Eyglo+M*^i_5hn%~}+j>NX$! zf)jsm(pfT6Sx{ox(fUhfS+nb|^(Vkv(R?ENd3&L$%?yVPXKm>TN4v^VF;}|AjE#4k z&u(_Yn9lMmH#*~uy8v(1`EzB*i|P$Y4baxnRNCxn?E4PzR@*wx^_P~^=k31Of5B3# zFMF{O@IK7H7w0h~yr{{CnQ7Lx%&~#uQN;UEZ>zKPcxrr0E_67ndrB&f>c0oPHCY4h z*vIL&o5hb)PuZ>a8Z(xnexgn|@|;6|#XZP%!j!{Ly3XYMHrNEcIZpHLKnVERo=S(= z)RoZ+$7&0Q^9GX>1YTP|86qgOkJ%m9<8(J;^KYdmIO0A>GBmj|WL=JH*r# z^_Ys>l}9X)8({=;o+p+NRJ|DNifPHoBJ*wi_YLKTEnK_3D-i87gf|cAJN(84GlWU{ z$-`Wsd;9>sD4);WkhR`x!foq57O12oB?v_u+&e!)$`GRUxFirqkBFo+N~w(Si&V%& z8k$tCUh zl%39rb|G?nTNFEQi<)9-wG!W?(I`oolqC-mv$jfEDZYuOr8<1GjwNP#&*6lMjHK0C zO@I&Oq&-cme_ZYZdCj(KDH*G#aiqtvEB_l0krNb4vbsfYs)VX3H7Q^HCNLS&WX`^^ zc>~y^(-3$VEnobm{Wk>7kZNj)53*fN6J#V6PRn*msmP_i*z07zB{e%qhMn&N?jR_F zCS{DTqmVFEW*MPjk)wG&`XLO*;af7!rB)hApw18!7aOy{$7WA39f-hSOLVDK^!*b!~Lxb?@VU=xbND(mPx(8&oZ7o zbbRaDrU~6^8QTw>>F8d)e3laf2xv1fGJ$Aj24)rpW>y9^c6J744hCjU24*e>W^M*% z9tLJ!24+5>5?P=tnfP};Tle6_=_j8!C-pzN&^u-M+nJ0Y=kI!a<>Axsf0i=dK7IUs z>+u8Y{{RJnfE_}yGBBOHG=KimGavV}-~HItc;WuR##dmC3>?WoWt%4KKQ?iG%gG+b zy$3qxox8K~k~&yBM>0e|n8U!zaQx@@mo4{~&Cgu7=i|NB1I?S{ATkULAO literal 0 HcmV?d00001 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