summaryrefslogtreecommitdiff
path: root/compiler/nativeGen
diff options
context:
space:
mode:
authorPeter Wortmann <scpmw@leeds.ac.uk>2014-12-18 21:11:23 +0100
committerAustin Seipp <austin@well-typed.com>2014-12-18 20:54:37 -0600
commitf85db7567210bc2ff7036064a26d6ba29998f025 (patch)
treea83b26055b1958c10cfc5c94e92799593c02822e /compiler/nativeGen
parent4c02b6f5dc4385369aa62160acd6037a32922f84 (diff)
downloadhaskell-f85db7567210bc2ff7036064a26d6ba29998f025.tar.gz
Some Dwarf generation fixes
- Make abbrev offset absolute on Non-Mac systems - Add another termination byte at the end of the abbrev section (readelf complains) - Scope combination was wrong for the simpler cases - Shouldn't have a "global/" in front of all scopes
Diffstat (limited to 'compiler/nativeGen')
-rw-r--r--compiler/nativeGen/Dwarf.hs4
-rw-r--r--compiler/nativeGen/Dwarf/Types.hs18
2 files changed, 18 insertions, 4 deletions
diff --git a/compiler/nativeGen/Dwarf.hs b/compiler/nativeGen/Dwarf.hs
index 4f9bdb64af..70fca4fdb7 100644
--- a/compiler/nativeGen/Dwarf.hs
+++ b/compiler/nativeGen/Dwarf.hs
@@ -83,8 +83,8 @@ compileUnitHeader unitU = sdocWithPlatform $ \plat ->
in vcat [ ptext (sLit "\t.long ") <> length -- compilation unit size
, ppr cuLabel <> colon
, ptext (sLit "\t.word 3") -- DWARF version
- , pprDwWord (ptext dwarfAbbrevLabel <> char '-' <>
- ptext dwarfAbbrevLabel) -- pointer to our abbrevs
+ , pprDwWord (sectionOffset dwarfAbbrevLabel dwarfAbbrevLabel)
+ -- abbrevs offset
, ptext (sLit "\t.byte ") <> ppr (platformWordSize plat) -- word size
]
diff --git a/compiler/nativeGen/Dwarf/Types.hs b/compiler/nativeGen/Dwarf/Types.hs
index 96fea0ab90..47e0bd1265 100644
--- a/compiler/nativeGen/Dwarf/Types.hs
+++ b/compiler/nativeGen/Dwarf/Types.hs
@@ -14,6 +14,7 @@ module Dwarf.Types
, pprLEBWord
, pprLEBInt
, wordAlign
+ , sectionOffset
)
where
@@ -94,7 +95,9 @@ pprAbbrevDecls haveDebugLine =
[ (dW_AT_name, dW_FORM_string)
, (dW_AT_low_pc, dW_FORM_addr)
, (dW_AT_high_pc, dW_FORM_addr)
- ]
+ ] $$
+ pprByte 0
+
-- | Generate assembly for DWARF data
pprDwarfInfo :: Bool -> DwarfInfo -> SDoc
pprDwarfInfo haveSrc d
@@ -113,7 +116,7 @@ pprDwarfInfoOpen haveSrc (DwarfCompileUnit _ name producer compDir lineLbl) =
$$ pprData4 dW_LANG_Haskell
$$ pprString compDir
$$ if haveSrc
- then pprData4' (ptext lineLbl <> char '-' <> ptext dwarfLineLabel)
+ then pprData4' (sectionOffset lineLbl dwarfLineLabel)
else empty
pprDwarfInfoOpen _ (DwarfSubprogram _ name label) = sdocWithDynFlags $ \df ->
pprAbbrev DwAbbrSubprogram
@@ -416,3 +419,14 @@ pprString = pprString' . hcat . map escape
char (intToDigit (ch `div` 64)) <>
char (intToDigit ((ch `div` 8) `mod` 8)) <>
char (intToDigit (ch `mod` 8))
+
+-- | Generate an offset into another section. This is tricky because
+-- this is handled differently depending on platform: Mac Os expects
+-- us to calculate the offset using assembler arithmetic. Meanwhile,
+-- GNU tools expect us to just reference the target directly, and will
+-- figure out on their own that we actually need an offset.
+sectionOffset :: LitString -> LitString -> SDoc
+sectionOffset target section = sdocWithPlatform $ \plat ->
+ case platformOS plat of
+ OSDarwin -> ptext target <> char '-' <> ptext section
+ _other -> ptext target