/
Draft_Assembly_Relocation_Table.xml
122 lines (110 loc) · 5.01 KB
/
Draft_Assembly_Relocation_Table.xml
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc strict="yes" ?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<?rfc private="RFC X____ (Draft-Asm)" ?>
<rfc ipr="none" number="____" category="info" docName="draft-assembly-relocation-table">
<front>
<title abbrev="Assembly Relocation Table">Assembly Relocation Table</title>
<author fullname="James Rhodes" initials="J.R." role="editor"
surname="Rhodes">
<organization>Redpoint Software</organization>
<address>
<email>jrhodes@redpointsoftware.com.au</email>
<uri>http://www.redpointsoftware.com.au/</uri>
</address>
</author>
<date month="April" year="2012" />
<area>Asm</area>
<workgroup>0x10c Standards Committee</workgroup>
<abstract>
<t>This draft provides a formal structure for providing an assembly
relocation table from within DCPU-16 programs.</t>
</abstract>
</front>
<middle>
<section title="Introduction">
<t>As it stands, code generated by assemblers is either not relocatable,
or the relocation format is not standardized. Thus this document
suggests a standard mechanism for providing a table of addresses that
need relocating.</t>
<section title="Requirements Language">
<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in <xref
target="RFC2119">RFC 2119</xref>.</t>
</section>
</section>
<section anchor="role-of-assemblers" title="Role of Assemblers">
<t>For the purposes of this draft, the role of assemblers is to generate
code from a defined syntax to DCPU-16 bytecode.</t>
<t>In this case, assemblers SHOULD provide an option to generate
relocatable code, but MUST NOT generate relocatable code unless the
user indicates that they wish to do so.</t>
</section>
<section anchor="relocation-table-format" title="Relocation Table Format">
<t>For purposes of future versioning, this document specifies version 1
of the relocation table format.</t>
<t>The format of the relocation table is as follows:</t>
<texttable anchor="relocation-table" title="Relocation Table">
<ttcol align="center">Contents of single Word</ttcol>
<c>Magic number</c>
<c>Version number</c>
<c>Size of table</c>
<c>Entry 1</c>
<c>...</c>
<c>Entry N</c>
</texttable>
<t>
<list style="hanging">
<t hangText="Magic number">The magic number consists of the string "RT"
(stands for "Relocation Table") as a packed 7-bit ASCII literal, thus
resulting in the value 0x5254.</t>
<t hangText="Version number">The current version number is 0x0001.</t>
<t hangText="Size of table">This field must be set to the total size of
the table, in words. This includes the magic number, the version
number and this field, too.</t>
<t hangText="Entries">Each entry is a absolute address pointing to a
single word in the file the relocation table is contained in, which
should be relocated relatively to the position the code is loaded to.
</t>
</list>
</t>
</section>
<section anchor="relocation-table-position" title="Relocation Table Positioning">
<t>The assembly relocation table must be positioned inside the generated
code, but have no effect on the program execution.</t>
<t>When an assembler generates relocatable code, the first instruction
MUST be a jump to the start of the actual program code. This results
in the first two words being:</t>
<texttable anchor="relocation-setup-table" title="Relocation Setup Table">
<ttcol align="center">Contents of single Word</ttcol>
<c>SET PC, <next word literally></c>
<c>Location of first program instruction</c>
</texttable>
<t>It is important to note that assemblers will have to offset all label
addresses by the size of the relocation table, plus the two words at
the start.</t>
</section>
<section anchor="security" title="Security Considerations">
<t>It is potentially possible for a malicious user to generate code
which determines the offset of the resulting relocatable program when
it is loaded into memory and executed.</t>
<t>This is possible by creating a label with a predetermined address if
the program was running at 0x0, and calculating the difference
between the actual address that the program would jump to and the
original value.</t>
</section>
</middle>
<back>
<references title="Normative References">
<?rfc include="reference.RFC.2119.xml"?>
</references>
</back>
</rfc>