This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Linker Policies in the Toolchain

By: a guest on Nov 4th, 2012  |  syntax: None  |  size: 5.29 KB  |  views: 563  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. (see the comments section of the Reddit post for what this all means)
  2.  
  3.  
  4.  
  5.  
  6.  
  7. --- DEFINING THE POLICY ---
  8.  
  9.  
  10.  
  11.  
  12.  
  13. james@server:~/0x10c-build> cat ../0x10c/kernel/stubsys/policy.example
  14. defaults
  15. {
  16.     kernel=@KERNEL_FOLDER@/stubsys.dkrn16
  17.     jumplist=@KERNEL_FOLDER@/stubsys.djmp16
  18.     symbols=@KERNEL_FOLDER@/stubsys.dsym16
  19. }
  20.  
  21. # image is the .executable format. for applications that will
  22. # be loaded at runtime.  if this is not defined, the linker will
  23. # use .image-direct. instead.
  24. format(image):
  25.     # offset all references to be relative to 0x1000
  26.     offset 0x1000
  27.     # call upon image-direct to perform the rest
  28.     chain image-direct
  29.  
  30. # image-direct is the .executable format. for applications that
  31. # are linked directly against the kernel.
  32. format(image-direct):
  33.     # write out the code (the linker has already
  34.     # attached the kernel)
  35.     write code
  36.  
  37. # internal format that writes the adjustment entries.
  38. internal(write-adjustment):
  39.     # write out adjustment table
  40.     write total(adjustment)
  41.     for $i from 0 to total(adjustment)
  42.         write field(adjustment, $i, address)
  43.     endfor
  44.  
  45. # internal format that writes the provided entries.
  46. internal(write-provided):
  47.     # write out provided table
  48.     write total(provided)
  49.     for $i from 0 to total(provided)
  50.         write field(provided, $i, label_size)
  51.         write field(provided, $i, label_text)
  52.         write field(provided, $i, address)
  53.     endfor
  54.  
  55. # shared is a custom format supported by this kernel
  56. # in this case it.s a shared library, but we can make
  57. # any definition here.
  58. format(shared):
  59.     # write out magic header
  60.     write words(0x8A5F, 0x68FF)
  61.     # write out tables
  62.     chain write-adjustment
  63.     chain write-provided
  64.     # write out the code
  65.     chain image-direct
  66.  
  67. # an example of defining a relocatable application
  68. format(relocatable):
  69.     # write out magic header
  70.     write words(0x1234, 0x5678)
  71.     # write out tables
  72.     chain write-adjustment
  73.     # write out the code
  74.     chain image-direct
  75.  
  76.  
  77.  
  78.  
  79.  
  80. --- PARSING THE POLICY ---
  81.  
  82.  
  83.  
  84.  
  85.  
  86. james@server:~/0x10c-build> dtpolicy/dtpolicy ../0x10c/kernel/stubsys/policy.example print        
  87. == settings ==
  88. kernel = @KERNEL_FOLDER@/stubsys.dkrn16
  89. jumplist = @KERNEL_FOLDER@/stubsys.djmp16
  90. symbols = @KERNEL_FOLDER@/stubsys.dsym16
  91.  
  92. == policies ==
  93.  - image
  94.  - image-direct
  95.  - write-adjustment
  96.  - write-provided
  97.  - shared
  98.  - relocatable
  99.  
  100. == policy: image ==
  101.     offset 4096
  102.     chain image-direct
  103.  
  104. == policy: image-direct ==
  105.     write code
  106.  
  107. == policy: write-adjustment ==
  108.     write total(adjustment)
  109.     for $i from 0 to total(adjustment)
  110.         write field(adjustment, $i, address)
  111.     endfor
  112.  
  113. == policy: write-provided ==
  114.     write total(provided)
  115.     for $i from 0 to total(provided)
  116.         write field(provided, $i, label_size)
  117.         write field(provided, $i, label_text)
  118.         write field(provided, $i, address)
  119.     endfor
  120.  
  121. == policy: shared ==
  122.     write words(35423, 26879)
  123.     chain write-adjustment
  124.     chain write-provided
  125.     chain image-direct
  126.  
  127. == policy: relocatable ==
  128.     write words(4660, 22136)
  129.     chain write-adjustment
  130.     chain image-direct
  131.  
  132.  
  133.  
  134.  
  135.  
  136. --- EVALUATING THE POLICY ---
  137.  
  138.  
  139.  
  140.  
  141.  
  142. james@server:~/0x10c-build> dtpolicy/dtpolicy ../0x10c/kernel/stubsys/policy.example execute image
  143. == executing: image ==
  144. offset called with 4096
  145. code called
  146. write called with:
  147.     1
  148.     2
  149.     3
  150.     4
  151.     5
  152.     6
  153. james@server:~/0x10c-build> dtpolicy/dtpolicy ../0x10c/kernel/stubsys/policy.example execute image-direct
  154. == executing: image-direct ==
  155. code called
  156. write called with:
  157.     1
  158.     2
  159.     3
  160.     4
  161.     5
  162.     6
  163. james@server:~/0x10c-build> dtpolicy/dtpolicy ../0x10c/kernel/stubsys/policy.example execute shared      
  164. == executing: shared ==
  165. write called with:
  166.     26320
  167.     26528
  168. total called with 278
  169. write called with:
  170.     3
  171. total called with 278
  172. added $i to the list of variables.
  173. field called with 278, 0, 288
  174. write called with:
  175. field called with 278, 1, 288
  176. write called with:
  177. field called with 278, 2, 288
  178. write called with:
  179. removed $i to the list of variables.
  180. total called with 279
  181. write called with:
  182.     3
  183. total called with 279
  184. added $i to the list of variables.
  185. field called with 279, 0, 286
  186. write called with:
  187. field called with 279, 0, 287
  188. write called with:
  189. field called with 279, 0, 288
  190. write called with:
  191. field called with 279, 1, 286
  192. write called with:
  193. field called with 279, 1, 287
  194. write called with:
  195. field called with 279, 1, 288
  196. write called with:
  197. field called with 279, 2, 286
  198. write called with:
  199. field called with 279, 2, 287
  200. write called with:
  201. field called with 279, 2, 288
  202. write called with:
  203. removed $i to the list of variables.
  204. code called
  205. write called with:
  206.     1
  207.     2
  208.     3
  209.     4
  210.     5
  211.     6
  212. james@server:~/0x10c-build> dtpolicy/dtpolicy ../0x10c/kernel/stubsys/policy.example execute relocatable
  213. == executing: relocatable ==
  214. write called with:
  215.     27480
  216.     27688
  217. total called with 278
  218. write called with:
  219.     3
  220. total called with 278
  221. added $i to the list of variables.
  222. field called with 278, 0, 288
  223. write called with:
  224. field called with 278, 1, 288
  225. write called with:
  226. field called with 278, 2, 288
  227. write called with:
  228. removed $i to the list of variables.
  229. code called
  230. write called with:
  231.     1
  232.     2
  233.     3
  234.     4
  235.     5
  236.     6
clone this paste RAW Paste Data