Browse files

Added RFC X1001 regarding the assembly relocation table format.

  • Loading branch information...
1 parent 9600e00 commit 7614f726584f540852303053b891b22e82cb804c @hach-que hach-que committed Apr 7, 2012
Showing with 327 additions and 0 deletions.
  1. +220 −0 ASM/Draft_Assembly_Relocation_Table.txt
  2. +107 −0 ASM/Draft_Assembly_Relocation_Table.xml
View
220 ASM/Draft_Assembly_Relocation_Table.txt
@@ -0,0 +1,220 @@
+RFC X1001 (Draft-Asm) J. Rhodes, Ed.
+ Redpoint Software
+ April 2012
+
+
+ Assembly Relocation Table
+
+Abstract
+
+ This draft provides a formal structure for providing an assembly
+ relocation table from within DCPU-16 programs.
+
+
+Table of Contents
+
+ 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 2
+ 1.1. Requirements Language . . . . . . . . . . . . . . . . . . . 2
+ 2. Role of Assemblers . . . . . . . . . . . . . . . . . . . . . . 2
+ 3. Relocation Table Format . . . . . . . . . . . . . . . . . . . . 2
+ 4. Relocation Table Position . . . . . . . . . . . . . . . . . . . 3
+ 5. Security Considerations . . . . . . . . . . . . . . . . . . . . 3
+ 6. Normative References . . . . . . . . . . . . . . . . . . . . . 3
+ Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Rhodes [Page 1]
+
+ Assembly Relocation Table April 2012
+
+
+1. Introduction
+
+ 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.
+
+1.1. Requirements Language
+
+ 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 RFC 2119 [RFC2119].
+
+
+2. Role of Assemblers
+
+ For the purposes of this draft, the role of assemblers is to generate
+ code from a defined syntax to DCPU-16 bytecode.
+
+ 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.
+
+
+3. Relocation Table Format
+
+ For purposes of future versioning, this document specifies version 1
+ of the relocation table format.
+
+ The format of the relocation table is as follows:
+
+ +-------------------------+
+ | Contents of single Word |
+ +-------------------------+
+ | Magic number (0x1234) |
+ | Version number (0x0001) |
+ | Size of table |
+ | Entry 1 |
+ | ... |
+ | Entry N |
+ +-------------------------+
+
+ Table 1: Relocation Table
+
+
+
+
+
+
+
+
+Rhodes [Page 2]
+
+ Assembly Relocation Table April 2012
+
+
+4. Relocation Table Position
+
+ The assembly relocation table must be positioned inside the generated
+ code, but have no effect on the program execution.
+
+ 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:
+
+ +---------------------------------------+
+ | Contents of single Word |
+ +---------------------------------------+
+ | SET PC, <next word literally> |
+ | Location of first program instruction |
+ +---------------------------------------+
+
+ Table 2: Relocation Setup Table
+
+ 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.
+
+
+5. Security Considerations
+
+ 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.
+
+ 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.
+
+
+6. Normative References
+
+ [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
+ Requirement Levels", BCP 14, RFC 2119, March 1997.
+
+
+
+
+
+
+
+
+
+
+
+
+Rhodes [Page 3]
+
+ Assembly Relocation Table April 2012
+
+
+Author's Address
+
+ James Rhodes (editor)
+ Redpoint Software
+
+ Email: jrhodes@redpointsoftware.com.au
+ URI: http://www.redpointsoftware.com.au/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Rhodes [Page 4]
View
107 ASM/Draft_Assembly_Relocation_Table.xml
@@ -0,0 +1,107 @@
+<?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 X1001 (Draft-Asm)" ?>
+<rfc ipr="none" number="1001" 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 (0x1234)</c>
+ <c>Version number (0x0001)</c>
+ <c>Size of table</c>
+ <c>Entry 1</c>
+ <c>...</c>
+ <c>Entry N</c>
+ </texttable>
+ </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, &lt;next word literally&gt;</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>
+

0 comments on commit 7614f72

Please sign in to comment.