2l 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. .TH 2L 1
  2. .SH NAME
  3. 1l, 2l, 5l, 7l, 8l, kl, ql, vl \- loaders
  4. .SH SYNOPSIS
  5. .B 2l
  6. [
  7. .I option ...
  8. ]
  9. [
  10. .I file ...
  11. ]
  12. .br
  13. etc.
  14. .SH DESCRIPTION
  15. These commands
  16. load the named
  17. .I files
  18. into executable files for the corresponding architectures; see
  19. .IR 2c (1)
  20. for the correspondence between an architecture and the character
  21. .RB ( 1 ,
  22. .RB 2 ,
  23. etc.) that specifies it.
  24. The files should be object files or libraries (archives of object files)
  25. for the appropriate architecture.
  26. Also, a name like
  27. .BI -l ext
  28. represents the library
  29. .BI lib ext .a
  30. in
  31. .BR /$objtype/lib ,
  32. where
  33. .I objtype
  34. is one of
  35. .BR 68000 ,
  36. etc. as listed in
  37. .IR 2c (1).
  38. The libraries must have tables of contents
  39. (see
  40. .IR ar (1)).
  41. .PP
  42. In practice,
  43. .B -l
  44. options are rarely necessary as the header files for
  45. the libraries cause their archives to be included automatically in the load
  46. (see
  47. .IR 2c (1)).
  48. For example, any program that includes header file
  49. .B libc.h
  50. causes the loader
  51. to search the C library
  52. .BR /$objtype/lib/libc.a .
  53. Also, the loader creates an undefined symbol
  54. .B _main
  55. (or
  56. .B _mainp
  57. if profiling is enabled) to force loading of the
  58. startup linkage from the C library.
  59. .PP
  60. The order of search to resolve undefined symbols is to load all files and libraries
  61. mentioned explicitly on the command line, and then to resolve remaining symbols
  62. by searching in topological order
  63. libraries mentioned in header files included by files already loaded.
  64. When scanning such libraries, the algorithm is to scan each library repeatedly until
  65. no new undefined symbols are picked up, then to start on the next library. Thus if library
  66. .I A
  67. needs
  68. .I B
  69. which needs
  70. .I A
  71. again, it may be necessary to mention
  72. .I A
  73. explicitly so it will be read a second time.
  74. .PP
  75. The loader options are:
  76. .TP 1i
  77. .B -l
  78. (As a bare option.)
  79. Suppress the default loading of the startup linkage and libraries
  80. specified by header files.
  81. .TP
  82. .BI -o " out"
  83. Place output in file
  84. .IR out .
  85. Default is
  86. .IB O .out\f1,
  87. where
  88. .I O
  89. is the first letter of the loader name.
  90. .TP
  91. .B -p
  92. Insert profiling code into the executable output; no special action is needed
  93. during compilation or assembly.
  94. .TP
  95. .B -s
  96. Strip the symbol tables from the output file.
  97. .TP
  98. .B -a
  99. Print the object code in assembly language, with addresses.
  100. .TP
  101. .B -v
  102. Print debugging output that annotates the activities of the load.
  103. .TP
  104. .BI -M
  105. .RI ( Kl
  106. only) Generate instructions rather than calls to emulation routines
  107. for multiply and divide.
  108. .TP
  109. .BI -E symbol
  110. The entry point for the binary is
  111. .I symbol
  112. (default
  113. .BR _main ;
  114. .B _mainp
  115. under
  116. .BR -p ).
  117. .TP
  118. .B -x
  119. [
  120. .I file
  121. ]
  122. Produce an export table in the executable.
  123. The optional
  124. .I file
  125. restricts the exported symbols to those listed in the file.
  126. See
  127. .IR dynld (2).
  128. .TP
  129. .B -u
  130. [
  131. .I file
  132. ]
  133. Produce an export table, import table
  134. and a dynamic load section in the executable.
  135. The optional
  136. .I file
  137. restricts the imported symbols to those listed in the file.
  138. See
  139. .IR dynld (2).
  140. .TP
  141. .BI -H n
  142. Executable header is type
  143. .IR n .
  144. The meaning of the types is architecture-dependent; typically
  145. type 1 is Plan 9 boot format and type 2 is the
  146. regular Plan 9 format, the default. These are reversed on the MIPS.
  147. The Next boot format is 3. Type 4 in
  148. .I vl
  149. creates a MIPS executable for an SGI Unix system.
  150. .TP
  151. .BI -T t
  152. The text segment starts at address
  153. .IR t .
  154. .TP
  155. .BI -D d
  156. The data segment starts at address
  157. .IR d .
  158. .TP
  159. .BI -R r
  160. The text segment is rounded to a multiple of
  161. .I r
  162. (if
  163. .I r
  164. is nonzero).
  165. .PP
  166. The numbers in the above options can begin with
  167. .L 0x
  168. or
  169. .L 0
  170. to change the default base from decimal to hexadecimal or octal.
  171. The defaults for the values depend on the compiler and the
  172. header type.
  173. .PP
  174. The loaded image has several symbols inserted by the loader:
  175. .B etext
  176. is the address of the end of the text segment;
  177. .B bdata
  178. is the address of the beginning of the data segment;
  179. .B edata
  180. is the address of the end of the data segment;
  181. and
  182. .B end
  183. is the address of the end of the bss segment, and of the program.
  184. .SH FILES
  185. .TF /$objtype/lib
  186. .TP
  187. .B /$objtype/lib
  188. for
  189. .BI -l lib
  190. arguments.
  191. .SH SOURCE
  192. .B /sys/src/cmd/2l
  193. etc.
  194. .SH "SEE ALSO"
  195. .IR 2c (1),
  196. .IR 2a (1),
  197. .IR ar (1),
  198. .IR nm (1),
  199. .IR db (1),
  200. .IR prof (1)
  201. .PP
  202. Rob Pike,
  203. ``How to Use the Plan 9 C Compiler''
  204. .SH BUGS
  205. The list of loaders given above is only partial,
  206. not all architectures are supported on all systems,
  207. some have been retired and some
  208. are provided by third parties.