summaryrefslogtreecommitdiff
path: root/types.myr
blob: f20cf006a9838b65a2989a70177f874c3f3ab1c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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[:]
		sect	: sect[:]

		/* 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
	;;

	type sect = struct
		name	: byte[:]
		flg	: uint32
	;;
;;