PIC Patch
Wolfgang Thaller
wolfgang.thaller at gmx.net
Tue Oct 5 00:45:06 EDT 2004
Hi!
The "backend" part of my PIC patches is basically finished; I'd like to
merge it into the HEAD soon, so that others can help me with the
"frontend" parts.
"Backend" here means that GHC can generate code that can be used in
shared libraries and code that can link to shared libraries, but
neither the fptools build system nor the GHC driver know anything about
that feature. That means that in order to create a dynamically-linked
executable you have to invoke ld manually for the libraries and for the
program.
PIC code generation should work on PowerPC platforms (Mac OS X and
Linux); support for x86 is not finished yet, but the patches shouldn't
break anything on non-PPC platforms (as long as you don't add -fPIC or
-dynamic to the command line).
About the patches:
One small thing is very ugly: I didn't find a proper way to get the
size of an info table in Cmm.h - can someone (Simon M?) please suggest
something that is better than the #if PROFILING ... 16 ... #else ... 8
.... #endif that you'll see in the attached patches?
Apart from that:
cmm/CLabel.hs:
Add support for DynamicLinkerLabels - for use inside the NCG.
needsCDecl: Case alternative labels now need C decls, see the
codeGen/CgInfoTbls.hs for details
cmm/Cmm.hs:
Add CmmPicBaseReg (used in NCG),
and CmmLabelDiffOff (used in NCG and for offsets in info tables)
cmm/CmmParse.y:
support offsets in info tables
cmm/PprC.hs:
support CmmLabelDiffOff
Case alternative labels now need C decls (see the codeGen/CgInfoTbls.hs
for details), so we need to pprDataExterns for info tables.
cmm/PprCmm.hs:
support CmmLabelDiffOff
codeGen/CgInfoTbls.hs:
no longer store absolute addresses in info tables, instead, we store
offsets.
Also, for vectored return points, emit the alternatives _after_ the
vector table. This is to work around a limitation in Apple's as, which
refuses to handle label differences where one label is at the end of a
section. Emitting alternatives after vector info tables makes sure this
never happens in GHC generated code. Case alternatives now require
prototypes in hc code, though (see changes in PprC.hs, CLabel.hs).
main/CmdLineOpts.lhs:
Add a new option, -fPIC.
main/DriverFlags.hs:
Pass the correct options for PIC to gcc, depending on the platform.
Only for powerpc for now.
nativeGen/AsmCodeGen.hs:
Many changes...
Mac OS X-specific management of import stubs is no longer, it's now
part of a general mechanism to handle such things for all platforms
that need it (Darwin [both ppc and x86], Linux on ppc, and some
platforms we don't support).
Move cmmToCmm into its own monad which can accumulate a list of
imported symbols. Make it call cmmMakeDynamicReference at the right
places.
nativeGen/MachCodeGen.hs:
nativeGen/MachInstrs.hs:
nativeGen/MachRegs.lhs:
nativeGen/PprMach.hs:
nativeGen/RegAllocInfo.hs:
Too many changes to enumerate here, PowerPC specific.
nativeGen/NCGMonad.hs:
NatM still tracks imported symbols, as more labels can be created
during code generation (float literals, jump tables; on some platforms
all data access has to go through the dynamic linking mechanism).
driver/mangler/ghc-asm.lprl:
Mangle absolute addresses in info tables to offsets.
Correctly pass through GCC-generated PIC for Mac OS X and powerpc linux.
includes/Cmm.h:
includes/InfoTables.h:
includes/Storage.h:
includes/mkDerivedConstants.c:
rts/GC.c:
rts/GCCompact.c:
rts/HeapStackCheck.cmm:
rts/Printer.c:
rts/RetainerProfile.c:
rts/Sanity.c:
Adapt to the fact that info tables now contain offsets.
rts/Linker.c:
Mac-specific: change machoInitSymbolsWithoutUnderscore to support PIC.
nativeGen/PositionIndependentCode.hs:
New file, attached separately.
OK, that's all. I'd like to get those patches committed to the HEAD as
soon as possible, so it'll be easier for other people to help
implementing the "front-end" parts.
Cheers,
Wolfgang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PositionIndependentCode.hs.gz
Type: application/x-gzip
Size: 5570 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/cvs-ghc/attachments/20041005/7ee8dfe3/PositionIndependentCode.hs-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ghc-pic-patch-04102004.patch.gz
Type: application/x-gzip
Size: 20952 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/cvs-ghc/attachments/20041005/7ee8dfe3/ghc-pic-patch-04102004.patch-0001.bin
-------------- next part --------------
More information about the Cvs-ghc
mailing list