(see the comments section of the Reddit post for what this all means)
--- DEFINING THE POLICY ---
james@server:~/0x10c-build> cat ../0x10c/kernel/stubsys/policy.example
defaults
{
kernel=@KERNEL_FOLDER@/stubsys.dkrn16
jumplist=@KERNEL_FOLDER@/stubsys.djmp16
symbols=@KERNEL_FOLDER@/stubsys.dsym16
}
# image is the .executable format. for applications that will
# be loaded at runtime. if this is not defined, the linker will
# use .image-direct. instead.
format(image):
# offset all references to be relative to 0x1000
offset 0x1000
# call upon image-direct to perform the rest
chain image-direct
# image-direct is the .executable format. for applications that
# are linked directly against the kernel.
format(image-direct):
# write out the code (the linker has already
# attached the kernel)
write code
# internal format that writes the adjustment entries.
internal(write-adjustment):
# write out adjustment table
write total(adjustment)
for $i from 0 to total(adjustment)
write field(adjustment, $i, address)
endfor
# internal format that writes the provided entries.
internal(write-provided):
# write out provided table
write total(provided)
for $i from 0 to total(provided)
write field(provided, $i, label_size)
write field(provided, $i, label_text)
write field(provided, $i, address)
endfor
# shared is a custom format supported by this kernel
# in this case it.s a shared library, but we can make
# any definition here.
format(shared):
# write out magic header
write words(0x8A5F, 0x68FF)
# write out tables
chain write-adjustment
chain write-provided
# write out the code
chain image-direct
# an example of defining a relocatable application
format(relocatable):
# write out magic header
write words(0x1234, 0x5678)
# write out tables
chain write-adjustment
# write out the code
chain image-direct
--- PARSING THE POLICY ---
james@server:~/0x10c-build> dtpolicy/dtpolicy ../0x10c/kernel/stubsys/policy.example print
== settings ==
kernel = @KERNEL_FOLDER@/stubsys.dkrn16
jumplist = @KERNEL_FOLDER@/stubsys.djmp16
symbols = @KERNEL_FOLDER@/stubsys.dsym16
== policies ==
- image
- image-direct
- write-adjustment
- write-provided
- shared
- relocatable
== policy: image ==
offset 4096
chain image-direct
== policy: image-direct ==
write code
== policy: write-adjustment ==
write total(adjustment)
for $i from 0 to total(adjustment)
write field(adjustment, $i, address)
endfor
== policy: write-provided ==
write total(provided)
for $i from 0 to total(provided)
write field(provided, $i, label_size)
write field(provided, $i, label_text)
write field(provided, $i, address)
endfor
== policy: shared ==
write words(35423, 26879)
chain write-adjustment
chain write-provided
chain image-direct
== policy: relocatable ==
write words(4660, 22136)
chain write-adjustment
chain image-direct
--- EVALUATING THE POLICY ---
james@server:~/0x10c-build> dtpolicy/dtpolicy ../0x10c/kernel/stubsys/policy.example execute image
== executing: image ==
offset called with 4096
code called
write called with:
1
2
3
4
5
6
james@server:~/0x10c-build> dtpolicy/dtpolicy ../0x10c/kernel/stubsys/policy.example execute image-direct
== executing: image-direct ==
code called
write called with:
1
2
3
4
5
6
james@server:~/0x10c-build> dtpolicy/dtpolicy ../0x10c/kernel/stubsys/policy.example execute shared
== executing: shared ==
write called with:
26320
26528
total called with 278
write called with:
3
total called with 278
added $i to the list of variables.
field called with 278, 0, 288
write called with:
field called with 278, 1, 288
write called with:
field called with 278, 2, 288
write called with:
removed $i to the list of variables.
total called with 279
write called with:
3
total called with 279
added $i to the list of variables.
field called with 279, 0, 286
write called with:
field called with 279, 0, 287
write called with:
field called with 279, 0, 288
write called with:
field called with 279, 1, 286
write called with:
field called with 279, 1, 287
write called with:
field called with 279, 1, 288
write called with:
field called with 279, 2, 286
write called with:
field called with 279, 2, 287
write called with:
field called with 279, 2, 288
write called with:
removed $i to the list of variables.
code called
write called with:
1
2
3
4
5
6
james@server:~/0x10c-build> dtpolicy/dtpolicy ../0x10c/kernel/stubsys/policy.example execute relocatable
== executing: relocatable ==
write called with:
27480
27688
total called with 278
write called with:
3
total called with 278
added $i to the list of variables.
field called with 278, 0, 288
write called with:
field called with 278, 1, 288
write called with:
field called with 278, 2, 288
write called with:
removed $i to the list of variables.
code called
write called with:
1
2
3
4
5
6