Info tables, like everything else in the text section, MUST NOT contain
pointers. A pointer is, by definition, position dependent and is therefore
fundamentally incompatible with generating position independent code.
Therefore, we have to store an offset from the info label to the string
instead of the pointer, just as we already did for other things referred
to by the info table (SRTs, large bitmaps, etc.)
- then mkStringCLit $ fromJust conIdentity
+ then do cstr <- mkStringCLit $ fromJust conIdentity
+ return (makeRelativeRefTo info_lbl cstr)
else return (mkIntCLit 0)
; emitInfoTableAndCode info_lbl std_info (extra_bits conName) args blks }
else return (mkIntCLit 0)
; emitInfoTableAndCode info_lbl std_info (extra_bits conName) args blks }
alignment conInfoTable = SIZEOF_VOID_P
peek ptr
= runState (castPtr ptr) $ do
alignment conInfoTable = SIZEOF_VOID_P
peek ptr
= runState (castPtr ptr) $ do
+#ifdef GHCI_TABLES_NEXT_TO_CODE
+#ifndef GHCI_TABLES_NEXT_TO_CODE
+ desc <- load
+#endif
+ {
+#ifdef GHCI_TABLES_NEXT_TO_CODE
+ conDesc = castPtr $ ptr `plusPtr` wORD_SIZE `plusPtr` desc
+#else
+ conDesc = desc
+#endif
, infoTable = itbl
}
poke ptr itbl
= runState (castPtr ptr) $ do
, infoTable = itbl
}
poke ptr itbl
= runState (castPtr ptr) $ do
+#ifdef GHCI_TABLES_NEXT_TO_CODE
+ store (conDesc itbl `minusPtr` (ptr `plusPtr` wORD_SIZE))
+#endif
+#ifndef GHCI_TABLES_NEXT_TO_CODE
+ store (conDesc itbl)
+#endif
data StgInfoTable = StgInfoTable {
#ifndef GHCI_TABLES_NEXT_TO_CODE
data StgInfoTable = StgInfoTable {
#ifndef GHCI_TABLES_NEXT_TO_CODE
getConDescAddress :: Ptr StgInfoTable -> IO (Ptr CChar)
getConDescAddress ptr = do
getConDescAddress :: Ptr StgInfoTable -> IO (Ptr CChar)
getConDescAddress ptr = do
- peek $ intPtrToPtr $ (ptrToIntPtr ptr) + offset
#ifdef GHCI_TABLES_NEXT_TO_CODE
#ifdef GHCI_TABLES_NEXT_TO_CODE
+ offsetToString <- peek $ intPtrToPtr $ (ptrToIntPtr ptr) + offset
+ return $ ptr `plusPtr` offsetToString
where
-- subtract a word number of bytes
offset = negate (fromIntegral SIZEOF_VOID_P)
#endif
#ifndef GHCI_TABLES_NEXT_TO_CODE
where
-- subtract a word number of bytes
offset = negate (fromIntegral SIZEOF_VOID_P)
#endif
#ifndef GHCI_TABLES_NEXT_TO_CODE
+ peek $ intPtrToPtr $ (ptrToIntPtr ptr) + offset
where
-- add the standard info table size in bytes
infoTableSizeBytes = sTD_ITBL_SIZE * wORD_SIZE
where
-- add the standard info table size in bytes
infoTableSizeBytes = sTD_ITBL_SIZE * wORD_SIZE
$line =~ s/$infoname/0/
|| $line =~ s/([A-Za-z0-9_]+_srtd)$/\1 - $infoname/
|| $line =~ s/([A-Za-z0-9_]+_srt(\+\d+)?)$/\1 - $infoname/
$line =~ s/$infoname/0/
|| $line =~ s/([A-Za-z0-9_]+_srtd)$/\1 - $infoname/
|| $line =~ s/([A-Za-z0-9_]+_srt(\+\d+)?)$/\1 - $infoname/
+ || $line =~ s/([A-Za-z0-9_]+_str)$/\1 - $infoname/
|| $line =~ s/([A-Za-z0-9_]+_slow)$/\1 - $infoname/
|| $line =~ s/([A-Za-z0-9_]+_btm)$/\1 - $infoname/
|| $line =~ s/([A-Za-z0-9_]+_alt)$/\1 - $infoname/
|| $line =~ s/([A-Za-z0-9_]+_slow)$/\1 - $infoname/
|| $line =~ s/([A-Za-z0-9_]+_btm)$/\1 - $infoname/
|| $line =~ s/([A-Za-z0-9_]+_alt)$/\1 - $infoname/