projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow access via manually generated SymbolPtrs. Generalize pprImportedSymbol for...
[ghc-hetmet.git]
/
compiler
/
nativeGen
/
PositionIndependentCode.hs
diff --git
a/compiler/nativeGen/PositionIndependentCode.hs
b/compiler/nativeGen/PositionIndependentCode.hs
index
523f305
..
2571b5c
100644
(file)
--- a/
compiler/nativeGen/PositionIndependentCode.hs
+++ b/
compiler/nativeGen/PositionIndependentCode.hs
@@
-48,7
+48,7
@@
module PositionIndependentCode (
#include "nativeGen/NCG.h"
import Cmm
#include "nativeGen/NCG.h"
import Cmm
-import MachOp ( MachOp(MO_Add), wordRep )
+import MachOp ( MachOp(MO_Add), wordRep, MachRep(..) )
import CLabel ( CLabel, pprCLabel,
mkDynamicLinkerLabel, DynamicLinkerLabelInfo(..),
dynamicLinkerLabelInfo, mkPicBaseLabel,
import CLabel ( CLabel, pprCLabel,
mkDynamicLinkerLabel, DynamicLinkerLabelInfo(..),
dynamicLinkerLabelInfo, mkPicBaseLabel,
@@
-131,7
+131,7
@@
cmmMakePicReference :: CLabel -> CmmExpr
-- everything gets relocated at runtime
cmmMakePicReference lbl
-- everything gets relocated at runtime
cmmMakePicReference lbl
- | opt_PIC && absoluteLabel lbl = CmmMachOp (MO_Add wordRep) [
+ | (opt_PIC || not opt_Static) && absoluteLabel lbl = CmmMachOp (MO_Add wordRep) [
CmmReg (CmmGlobal PicBaseReg),
CmmLit $ picRelative lbl
]
CmmReg (CmmGlobal PicBaseReg),
CmmLit $ picRelative lbl
]
@@
-200,7
+200,7
@@
howToAccessLabel DataReference lbl
| otherwise = AccessDirectly
| otherwise = AccessDirectly
-#if x86_TARGET_ARCH || x86_64_TARGET_ARCH
+#if i386_TARGET_ARCH || x86_64_TARGET_ARCH
-- dyld code stubs don't work for tailcalls because the
-- stack alignment is only right for regular calls.
-- Therefore, we have to go via a symbol pointer:
-- dyld code stubs don't work for tailcalls because the
-- stack alignment is only right for regular calls.
-- Therefore, we have to go via a symbol pointer:
@@
-269,12
+269,12
@@
howToAccessLabel DataReference lbl
-- (AccessDirectly, because we get an implicit symbol stub)
-- and calling functions from PIC code on non-i386 platforms (via a symbol stub)
-- (AccessDirectly, because we get an implicit symbol stub)
-- and calling functions from PIC code on non-i386 platforms (via a symbol stub)
-howToAccessLabel CallLabel lbl
+howToAccessLabel CallReference lbl
| labelDynamic lbl && not opt_PIC
= AccessDirectly
#if !i386_TARGET_ARCH
| labelDynamic lbl && opt_PIC
| labelDynamic lbl && not opt_PIC
= AccessDirectly
#if !i386_TARGET_ARCH
| labelDynamic lbl && opt_PIC
- = AccessViaSymbolStub
+ = AccessViaStub
#endif
howToAccessLabel _ lbl
#endif
howToAccessLabel _ lbl
@@
-372,6
+372,9
@@
pprGotDeclaration = Pretty.empty
-- On Darwin, we have to generate our own stub code for lazy binding..
-- For each processor architecture, there are two versions, one for PIC
-- and one for non-PIC.
-- On Darwin, we have to generate our own stub code for lazy binding..
-- For each processor architecture, there are two versions, one for PIC
-- and one for non-PIC.
+--
+-- Whenever you change something in this assembler output, make sure
+-- the splitter in driver/split/ghc-split.lprl recognizes the new output
pprImportedSymbol importedLbl
#if powerpc_TARGET_ARCH
| Just (CodeStub, lbl) <- dynamicLinkerLabelInfo importedLbl
pprImportedSymbol importedLbl
#if powerpc_TARGET_ARCH
| Just (CodeStub, lbl) <- dynamicLinkerLabelInfo importedLbl
@@
-442,7
+445,7
@@
pprImportedSymbol importedLbl
ptext SLIT("1:"),
ptext SLIT("\tmovl L") <> pprCLabel_asm lbl
<> ptext SLIT("$lazy_ptr-1b(%eax),%edx"),
ptext SLIT("1:"),
ptext SLIT("\tmovl L") <> pprCLabel_asm lbl
<> ptext SLIT("$lazy_ptr-1b(%eax),%edx"),
- ptext SLIT("\tjmp %edx"),
+ ptext SLIT("\tjmp *%edx"),
ptext SLIT("L") <> pprCLabel_asm lbl
<> ptext SLIT("$stub_binder:"),
ptext SLIT("\tlea L") <> pprCLabel_asm lbl
ptext SLIT("L") <> pprCLabel_asm lbl
<> ptext SLIT("$stub_binder:"),
ptext SLIT("\tlea L") <> pprCLabel_asm lbl
@@
-527,7
+530,7
@@
pprGotDeclaration
ptext SLIT(".LCTOC1 = .+32768")
]
ptext SLIT(".LCTOC1 = .+32768")
]
--- We generate one .long literal for every symbol we import;
+-- We generate one .long/.quad literal for every symbol we import;
-- the dynamic linker will relocate those addresses.
pprImportedSymbol importedLbl
-- the dynamic linker will relocate those addresses.
pprImportedSymbol importedLbl
@@
-535,11
+538,16
@@
pprImportedSymbol importedLbl
= vcat [
ptext SLIT(".section \".got2\", \"aw\""),
ptext SLIT(".LC_") <> pprCLabel_asm lbl <> char ':',
= vcat [
ptext SLIT(".section \".got2\", \"aw\""),
ptext SLIT(".LC_") <> pprCLabel_asm lbl <> char ':',
- ptext SLIT("\t.long") <+> pprCLabel_asm lbl
+ ptext symbolSize <+> pprCLabel_asm lbl
]
-- PLT code stubs are generated automatically be the dynamic linker.
| otherwise = empty
]
-- PLT code stubs are generated automatically be the dynamic linker.
| otherwise = empty
+ where
+ symbolSize = case wordRep of
+ I32 -> SLIT("\t.long")
+ I64 -> SLIT("\t.quad")
+ _ -> panic "Unknown wordRep in pprImportedSymbol"
#else
#else