X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FnativeGen%2FPprMach.lhs;h=3bab396d9408fb4b791f85936fe36c0a08f15024;hb=5819de0c5d78effa16e4c59987268eadb96b8d1d;hp=1265384ea7ae9146f7163d5cd6af585d38747d3a;hpb=2ae353a8f2af07cbe01d8817e93b28f65332c6fa;p=ghc-hetmet.git diff --git a/ghc/compiler/nativeGen/PprMach.lhs b/ghc/compiler/nativeGen/PprMach.lhs index 1265384..3bab396 100644 --- a/ghc/compiler/nativeGen/PprMach.lhs +++ b/ghc/compiler/nativeGen/PprMach.lhs @@ -10,7 +10,7 @@ We start with the @pprXXX@s with some cross-platform commonality \begin{code} #include "nativeGen/NCG.h" -module PprMach ( pprInstr, pprSize, pprUserReg ) where +module PprMach ( pprInstr, pprSize, pprUserReg IF_OS_darwin(COMMA pprDyldSymbolStub, ) ) where #include "HsVersions.h" @@ -2037,6 +2037,34 @@ pprRI (RIImm r) = pprImm r pprFSize DF = empty pprFSize F = char 's' +{- + The Mach-O object file format used in Darwin/Mac OS X needs a so-called + "symbol stub" for every function that might be imported from a dynamic + library. + The stubs are always the same, and they are all output at the end of the + generated assembly (see AsmCodeGen.lhs), so we don't use the Instr datatype. + Instead, we just pretty-print it directly. +-} + +#if darwin_TARGET_OS +pprDyldSymbolStub fn = + vcat [ + ptext SLIT(".symbol_stub"), + ptext SLIT("L_") <> ftext fn <> ptext SLIT("$stub:"), + ptext SLIT("\t.indirect_symbol _") <> ftext fn, + ptext SLIT("\tlis r11,ha16(L_") <> ftext fn <> ptext SLIT("$lazy_ptr)"), + ptext SLIT("\tlwz r12,lo16(L_") <> ftext fn <> ptext SLIT("$lazy_ptr)(r11)"), + ptext SLIT("\tmtctr r12"), + ptext SLIT("\taddi r11,r11,lo16(L_") <> ftext fn <> ptext SLIT("$lazy_ptr)"), + ptext SLIT("\tbctr"), + ptext SLIT(".lazy_symbol_pointer"), + ptext SLIT("L_") <> ftext fn <> ptext SLIT("$lazy_ptr:"), + ptext SLIT("\t.indirect_symbol _") <> ftext fn, + ptext SLIT("\t.long dyld_stub_binding_helper") + ] +#endif + + #endif {-powerpc_TARGET_ARCH-} \end{code}