summary refs log tree commit diff
path: root/elf.e
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-05-23 22:47:35 -0700
committerIrene Knapp <ireneista@irenes.space>2026-05-23 22:47:35 -0700
commitfa77a37199208fa207202e62f409e1371c5f03f3 (patch)
treefc58aee7e0fbd3dc012277724622a75a3f4a9ff0 /elf.e
parentd65031570a3f678b03b29ea8a2293e0b8fad7907 (diff)
added a couple new instructions
this turns out to be fairly involved. hex bootstrap can't come fast enough ;)

Force-Push: yes
Change-Id: Ide5d2207d745ad07c40d3c9f457cd6b491bfbcf0
Diffstat (limited to 'elf.e')
-rw-r--r--elf.e26
1 files changed, 26 insertions, 0 deletions
diff --git a/elf.e b/elf.e
index 68eb6f2..7801bf6 100644
--- a/elf.e
+++ b/elf.e
@@ -107,6 +107,32 @@
   ~ program header's size.
   current-offset 4 roll - L!' elf-program-header-size ;
 
+
+~   This alternate version of the program header isn't used by evoke.e, but
+~ may be useful for other programs, such as hex.e. Its only difference from
+~ the base version is that it adds the write permission.
+: elf-program-header-writable
+  ~ * denotes mandatory fields according to breadbox
+  current-offset L!' elf-program-header
+  current-offset 3unroll
+
+  1 pack32                              ~ *"loadable" segment type
+  0x07 pack32                           ~ *read+write+execute permission
+  0 pack64                              ~ *offset in file
+  L@' origin pack64                     ~ *virtual address
+    ~ required, but can be anything, subject to alignment
+  0 pack64                              ~ physical address (ignored)
+
+  L@' total-size pack64                 ~ *size in file
+  L@' total-size pack64                 ~ *size in memory
+
+  0 pack64                              ~ segment alignment
+    ~ for relocation, but this doesn't apply to us
+
+  ~   As with the file header, we use the label system to keep track of the
+  ~ program header's size.
+  current-offset 4 roll - L!' elf-program-header-size ;
+
 ~ ~~~~~~~~~~~~~~~~
 ~ ~~ That's it! ~~
 ~ ~~~~~~~~~~~~~~~~