diff options
Diffstat (limited to 'compiler/nativeGen/Dwarf')
-rw-r--r-- | compiler/nativeGen/Dwarf/Constants.hs | 12 | ||||
-rw-r--r-- | compiler/nativeGen/Dwarf/Types.hs | 14 |
2 files changed, 15 insertions, 11 deletions
diff --git a/compiler/nativeGen/Dwarf/Constants.hs b/compiler/nativeGen/Dwarf/Constants.hs index 2cd54a7ceb..4b334fca3d 100644 --- a/compiler/nativeGen/Dwarf/Constants.hs +++ b/compiler/nativeGen/Dwarf/Constants.hs @@ -122,12 +122,14 @@ dwarfFrameSection = dwarfSection "frame" dwarfGhcSection = dwarfSection "ghc" dwarfSection :: String -> SDoc -dwarfSection name = sdocWithPlatform $ \plat -> +dwarfSection name = sdocWithPlatform $ \plat -> ftext $ mkFastString $ case platformOS plat of - OSDarwin -> ftext $ mkFastString $ - ".section __DWARF,__debug_" ++ name ++ ",regular,debug" - _other -> ftext $ mkFastString $ - ".section .debug_" ++ name ++ ",\"\",@progbits" + os | osElfTarget os + -> "\t.section .debug_" ++ name ++ ",\"\",@progbits" + | osMachOTarget os + -> "\t.section __DWARF,__debug_" ++ name ++ ",regular,debug" + | otherwise + -> "\t.section .debug_" ++ name ++ ",\"dr\"" -- | Dwarf section labels dwarfInfoLabel, dwarfAbbrevLabel, dwarfLineLabel, dwarfFrameLabel :: LitString diff --git a/compiler/nativeGen/Dwarf/Types.hs b/compiler/nativeGen/Dwarf/Types.hs index 520b5ae027..00d0535a07 100644 --- a/compiler/nativeGen/Dwarf/Types.hs +++ b/compiler/nativeGen/Dwarf/Types.hs @@ -119,7 +119,7 @@ pprDwarfInfoOpen haveSrc (DwarfCompileUnit _ name producer compDir lineLbl) = $$ pprString compDir $$ pprFlag True -- use UTF8 $$ if haveSrc - then pprData4' (sectionOffset lineLbl dwarfLineLabel) + then sectionOffset lineLbl dwarfLineLabel else empty pprDwarfInfoOpen _ (DwarfSubprogram _ name label) = sdocWithDynFlags $ \df -> pprAbbrev DwAbbrSubprogram @@ -431,11 +431,13 @@ escapeChar c -- | 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. +-- us to calculate the offset using assembler arithmetic. Linux expects +-- us to just reference the target directly, and will figure out on +-- their own that we actually need an offset. Finally, Windows has +-- a special directive to refer to relative offsets. Fun. sectionOffset :: LitString -> LitString -> SDoc sectionOffset target section = sdocWithPlatform $ \plat -> case platformOS plat of - OSDarwin -> ptext target <> char '-' <> ptext section - _other -> ptext target + OSDarwin -> pprDwWord (ptext target <> char '-' <> ptext section) + OSMinGW32 -> text "\t.secrel32 " <> ptext target + _other -> pprDwWord (ptext target) |