summaryrefslogtreecommitdiff
path: root/types.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-09-25 19:19:54 -0700
committerOri Bernstein <ori@eigenstate.org>2017-09-25 23:58:02 -0700
commit2eb61ae0040a66043b41863c2348fdacd37cc091 (patch)
treeaeb4cbf7fe1ffa2ea59ed2479cb541c0f384aebd /types.myr
downloadlnk-2eb61ae0040a66043b41863c2348fdacd37cc091.tar.gz
Linker: Initial commit.
Diffstat (limited to 'types.myr')
-rw-r--r--types.myr73
1 files changed, 73 insertions, 0 deletions
diff --git a/types.myr b/types.myr
new file mode 100644
index 0000000..818442e
--- /dev/null
+++ b/types.myr
@@ -0,0 +1,73 @@
+use std
+
+pkg =
+ /* relocation kinds */
+ const Rel8 : uint32 = 1
+ const Rel16 : uint32 = 2
+ const Rel32 : uint32 = 3
+ const Rel64 : uint32 = 4
+ const Relbase : uint32 = 5
+ const Relkind : uint32 = 0xffff
+ const Relabs : uint32 = 1 << 16
+ const Relarg : uint32 = 1 << 17
+
+ /* sym kinds */
+ const Symdat : uint32 = 1
+ const Symtxt : uint32 = 2
+ const Symbss : uint32 = 3
+ const Symro : uint32 = 4
+ const Symusr : uint32 = 5
+ const Symkind : uint32 = 0xffff
+
+ /* sym flags */
+ const Symonce : uint32 = 1 << 16
+
+ type lnk = struct
+ /* input */
+ obj : obj[:]
+
+ /* output */
+ text : byte[:]
+ data : byte[:]
+ rodata : byte[:]
+ bss : uint64
+
+ /* emission state */
+ base : uint64
+ entry : uint64
+ foff : uint64
+ voff : uint64
+ outf : byte[:]
+ sys : byte[:]
+ cur : byte[:] /* current output symbol buffer */
+ stab : std.htab(byte[:], sym#)#
+ ;;
+
+ type obj = struct
+ sym : sym[:]
+ rel : rel[:]
+ buf : byte[:]
+ str : byte[:]
+
+ /* state */
+ path : byte[:]
+ ;;
+
+ type sym = struct
+ /* input */
+ name : byte[:]
+ kind : uint32
+ buf : byte[:]
+ len : uint64
+
+ /* state */
+ off : uint64
+ ;;
+
+ type rel = struct
+ sym : byte[:]
+ kind : uint32
+ off : uint64
+ arg : uint64
+ ;;
+;;