Changes between Version 1 and Version 2 of Commentary/PositionIndependentCode


Ignore:
Timestamp:
Jun 27, 2007 10:31:29 AM (7 years ago)
Author:
guest
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/PositionIndependentCode

    v1 v2  
    66 
    77To access things defined in a dynamic library, we might need to do special things, such as look up the address of the imported thing in a table of pointers, depending on what platform we are on. 
     8 
     9== How to access symbols == 
     10 
     11A C compiler is in an unfortunate position when generating PIC code, as it does not have any hints, whether an accessed symbol ends up in the same dynamic library or if it is truely an external symbol (from the dynamic library point of view). It can only generate non-PIC access for symbols generated within the same object file. In Haskell, we can do better as we assume all package code to end up in a single dynamic library. Hence, all intra-package symbol accesses can be generated as code that does direct access. For all inter-package accesses (package haskell98 accessing symbols in package base, e.g.), we have to generate PIC code. For the following we establish the following:  
     12 
     13 * ''object-local symbols'', symbols within the same object file. Always generate direct access.  
     14 * ''package-local symbols'', symbols within the same Haskell package. The NCG can generate direct access code, C compilers can't. 
     15 * ''local symbols'', either object-local or package-local. 
     16 * ''global symbols'', symbol in different libraries/packages. Always generate PIC. 
    817 
    918== CLabel.labelDynamic ==