5 This document is a draft and is subject to change.
8 This part of the file describes the conventions required to write
9 ELF object files that are link-compatible with the ones produced
10 by the GNU toolchains.
15 This implementation is little-endian. Bits are numbered starting
18 In this document, 'word' means 16 bits.
23 The registers are allocated as follows:
26 -------------------------------------------------------------------
27 r0, r1 Call-volatile. May be changed during the execution
28 of a call instruction.
29 r2 through r7 Argument passing; call-clobbered.
30 r8, r9 Call-volatile. May be changed during the execution
31 of a call instruction.
32 r10 through r13 Call-saved.
33 r14 Program status word.
37 Scalar values are returned in register r2-r7 if the value fits.
38 Otherwise, a pointer is passed as a 'hidden' first argument and
39 the return value is placed there.
41 Arguments are passed in registers starting in r2, then on the stack.
42 Arguments of size not a multiple of a word are padded to whole words.
43 If an argument would otherwise be passed partially in registers, and
44 partially on the stack, the whole of it is passed on the stack. The
45 last argument is pushed on the stack first.
47 After a procedure's arguments are pushed on the stack,
48 the return address is pushed on the stack, as if by the call
49 instruction. The return address is on the top of the stack when
50 a procedure is called.
52 Objects whose size is a multiple of 16 bits are aligned to a 16-bit
55 Pointers are 16 bits, referencing addresses between 0 and 0xFFFF.
57 Procedure pointers are also implemented as 16-bit pointers.
59 Variable Argument Functions
60 ===========================
62 The C type 'va_list' is implemented as a structure, as follows:
69 Both fields are 16 bits. An argument of size N bytes
70 (N will be even) is accessed as if by the following code:
73 /* count = #bytes non-variable arguments */
74 /* 12 = #bytes for register arguments */
79 result = base - (count + N - 12 + 4);
83 result = base + count;
86 /* The argument is at `*result'. */
89 One implementation of this is if a variadic function first
90 pushes registers 2 through 7 in sequence at entry, and
91 sets 'base' to the address of the first word pushed,
92 producing a stack that appears like:
102 Return address (two words)
103 7th procedure parameter word
104 8th procedure parameter word
106 last procedure parameter word
108 and initialises 'count' to be the number of bytes of non-variable
109 arguments to the function.
117 Stormy16 ELF files are distinguished by the value EM_STORMY16 in
118 the e_machine field of the ELF file header:
120 #define EM_STORMY16 0xad45
122 DWARF Register Number Mapping
123 -----------------------------
125 Registers r0 through r15 are mapped to numbers 0 through 15.
130 RELA relocs are used exclusively. The relocation types defined are:
132 Name Value Field Calculation Overflow
133 ----------------------------------------------------------------
134 R_STORMY16_NONE 0 none none none
135 R_STORMY16_32 1 32 S + A none
136 R_STORMY16_16 2 16 S + A unsigned
137 R_STORMY16_8 3 8 S + A unsigned
138 R_STORMY16_PC32 4 32 S + A - P none
139 R_STORMY16_PC16 5 16 S + A - P signed
140 R_STORMY16_PC8 6 8 S + A - P signed
141 R_STORMY16_REL_12 7 16:12:0 S + A - P signed
142 R_STORMY16_24 8 32:23:1 (S + A) >> 1 unsigned
143 R_STORMY16_GNU_VTINHERIT 9 n/a n/a n/a
144 R_STORMY16_GNU_VTENTRY 10 n/a n/a n/a
146 In the 'Calculation' column, 'S' is the value of the symbol to which
147 the reloc refers, 'A' is the addend, and 'P' represents the place of
148 the storage unit being relocated.
150 In the 'Field' column, the first number indicates whether the
151 relocation refers to a byte, word or doubleword. The second number,
152 if any, indicates the size of the bitfield into which the relocation
153 is to occur (and also the size for overflow checking). The third
154 number indicates the first bit of the bitfield in the word or
155 doubleword, counting the LSB as bit 0.