On the Atari it seems reasonable to start on a clear b&w screen even for non-CTK...
[contiki-2.x.git] / core / loader / cle.h
blob8c15b40803022466d6177dae6be95cdfe6ff0ffa
1 /*
2 * Copyright (c) 2006, Swedish Institute of Computer Science
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the Institute nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
29 * @(#)$Id: cle.h,v 1.7 2007/06/04 17:47:56 bg- Exp $
32 #ifndef CLE_H
33 #define CLE_H
36 * The Contiki dynamic Link Editor (CLE) for small systems.
39 /* These typedefs limits object file size! */
40 typedef u16_t cle_off; /* Offset from start of file. */
41 typedef u16_t cle_word;
42 typedef u16_t cle_half;
44 /* Also used for address arithmetic (can't be void *). */
45 #ifdef __AVR__
46 typedef uint32_t cle_addr;
47 #else
48 typedef uintptr_t cle_addr;
49 #endif
51 typedef char cle_scratch[32];
53 struct cle_info {
54 cle_addr text;
55 void *data, *bss;
57 cle_off textrelaoff, datarelaoff;
58 cle_word textrelasize, datarelasize;
60 cle_off textoff, dataoff;
61 cle_word textsize, datasize, bsssize;
63 cle_off symtaboff, strtaboff;
64 cle_word symtabsize;
66 unsigned char text_shndx;
67 unsigned char data_shndx;
68 unsigned char bss_shndx;
69 unsigned char unused_shndx;
71 cle_scratch name; /* Scratch and errmsg buffer. */
74 int
75 cle_read_info(struct cle_info *info,
76 int (*read)(void *, int, off_t),
77 off_t hdr); /* Offset to start of file. */
79 int
80 cle_relocate(struct cle_info *info,
81 int (*read)(void *, int, off_t),
82 off_t hdr, /* Offset to start of file. */
83 void *segmem, /* Where segment is stored in memory. */
84 cle_off reloff, /* .rela.<segment> start */
85 cle_word relsize); /* .rela.<segment> size */
87 void *
88 cle_lookup(struct cle_info *info,
89 int (*read)(void *, int, off_t),
90 off_t hdr, /* Offset to start of file. */
91 const char *symbol);
93 struct elf32_rela; /* Struct forward decl. */
95 int cle_write_reloc(void *,
96 const struct elf32_rela *,
97 cle_addr,
98 const struct cle_info *);
101 * Error codes that apply in general to linking and loading.
103 #define CLE_OK 0
104 #define CLE_BAD_HEADER 1
105 #define CLE_NO_SYMTAB 2
106 #define CLE_NO_STRTAB 3
107 #define CLE_NO_TEXT 4
108 #define CLE_UNDEFINED 5
109 #define CLE_UNKNOWN_SEGMENT 6
110 #define CLE_NO_STARTPOINT 7
111 #define CLE_TEXT_TO_LARGE 8
112 #define CLE_DATA_TO_LARGE 9
113 #define CLE_UNKNOWN_RELOC 10
114 #define CLE_MULTIPLY_DEFINED 11
116 #endif /* CLE_H */