Next: , Previous: , Up: objects codes reloc   [Index]


13.23.3.2 Records of type: foreign address

These records are composed of 2 words: the second word contains a tagged pointer referencing a bytevector object holding the C string representation of a foreign object name, in the format suitable to be handed to dlsym(). When these records are processed: dlsym() is used to retrieve the address of the foreign object (which must be present in the global namespace), then the address is stored directly in the target word in the data area of the subject code object.

   meta data         data area
  |.........|..........................|

s_code   p_data
  v         v
  |---------|--------------|---|-------| code object
            |..............|...|target word
      ------->displacement   ^
     |                       |
     |     --- dlsym() ------
     |    |
     |    |
  |----|----| foreign object record
   1st  2nd

Records of this type are used when the code performs a call to a C function, not using the foreign–functions interface. For example, let’s consider this code:

(define (f x)
  (foreign-call "ikrt_glibc_csin" x))

the relocation vector references a bytevector containing the ASCIIZ representation of ikrt_glibc_csin.

Examples of C functions used in this way are: the C functions exported by the executable program vicare to be called from Scheme; the C functions exported by shared libraries when using extensions like Vicare/SQLite and Vicare/cURL. The foreign–functions interface does not make use of this mechanism.