Commit 3640ae92 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

Dwarf: Use .short instead of .hword on Darwin

Apparently gnu as uses `.short` as a synonym for `.word`. To emit a
16-bit value one would use `.hword`. However, Darwin doesn't support
`.hword`, instead taking `.short` to mean a 16-bit value. The
insanity is nearly unbearable!

OS X reference:
https://developer.apple.com/library/mac/documentation/DeveloperTools/Ref
erence/Assembler/040-Assembler_Directives/asm_directives.html#//apple_re
f/doc/uid/TP30000823-TPXREF101

gnu as reference:
https://sourceware.org/binutils/docs/as/hword.html#hword

Test Plan: Validate

Reviewers: austin

Reviewed By: austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1602

GHC Trac Issues: #11202
parent 4935b48b
......@@ -477,7 +477,14 @@ pprByte x = ptext (sLit "\t.byte ") <> ppr (fromIntegral x :: Word)
-- | Assembly for a two-byte constant integer
pprHalf :: Word16 -> SDoc
pprHalf x = ptext (sLit "\t.hword ") <> ppr (fromIntegral x :: Word)
pprHalf x = sdocWithPlatform $ \plat ->
-- Naturally Darwin doesn't support `.hword` and binutils uses `.short`
-- as a synonym for `.word` (but only some of the time!). The madness
-- is nearly too much to bear.
let dir = case platformOS plat of
OSDarwin -> text ".short"
_ -> text ".hword"
in text "\t" <> dir <+> ppr (fromIntegral x :: Word)
-- | Assembly for a constant DWARF flag
pprFlag :: Bool -> SDoc
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment