insert_kernel_libs.hss 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. [Main]
  2. Title=__ld_insert_kernel_libs
  3. See Also=insert_fargo020_libs: __ld_insert_fargo020_libs, insert_fargo021_libs: __ld_insert_fargo021_libs
  4. [Top]
  5. __ld_insert_kernel_libs can be used to handle
  6. <A HREF="$$LINK(symbols_lib_call)">library calls</A>. It inserts references
  7. to libraries in the format used by kernels:
  8. <UL>
  9. <LI>For each referenced library...
  10. <UL>
  11. <LI><B>8 bytes:</B> library variable name</LI>
  12. <LI><B>1 byte:</B> 0</LI>
  13. <LI><B>1 byte:</B> minimum version number (see
  14. <A HREF="$$LINK(control_lib_min_version)">Minimum Library
  15. Versions</A>)</LI>
  16. </UL></LI>
  17. <LI>For each referenced library (again)...
  18. <UL>
  19. <LI><B>2 bytes:</B> number of imported functions/variables minus 1</LI>
  20. <LI>For each imported function/variable...
  21. <UL>
  22. <LI><B>2 bytes:</B> <I>index</I> of the function/variable</LI>
  23. <LI>Relocation table for this function/variable:
  24. <UL>
  25. <LI>For each reference...
  26. <UL>
  27. <LI><B>2 bytes:</B> <I>location</I> (may not be 0)</LI>
  28. </UL></LI>
  29. <LI><B>2 bytes:</B> 0</LI>
  30. </UL></LI>
  31. </UL></LI>
  32. </UL></LI>
  33. </UL>
  34. If a program uses this insertion, it must process it as follows:
  35. <UL>
  36. <LI>For each library...
  37. <UL>
  38. <LI>Do whatever is necessary to check the version and load it into the
  39. program's address space;</LI>
  40. <LI>For each relocation entry...
  41. <UL>
  42. <LI>Get the starting address of the program (via
  43. <A HREF="$$LINK(symbols_ld_entry_point)">__ld_entry_point</A>);</LI>
  44. <LI>Add the <I>location</I> value;</LI>
  45. <LI>Modify the 4-byte value (<I>offset</I>) at the resulting address:
  46. <UL>
  47. <LI>Get the address of the library function/variable indexed by
  48. <I>index</I>;</LI>
  49. <LI>Add the value of <I>offset</I>;</LI>
  50. <LI>Write the resulting address to the 4-byte space covered by
  51. <I>offset</I>.</LI>
  52. </UL></LI>
  53. </UL></LI>
  54. </UL></LI>
  55. </UL>
  56. Before program termination, this process has to be reverted, so that it can
  57. be repeated the next time the program starts. Since programs and libraries
  58. may be moved in memory while they are not executed, they may <I>not</I>
  59. simply deactivate the relocation code. This would also prevent programs from
  60. being transferred between devices.