Contiki 2.5
elfloader-arch-otf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005, Swedish Institute of Computer Science
3  * Copyright (c) 2007, Simon Berg
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the Institute nor the names of its contributors
15  * may be used to endorse or promote products derived from this software
16  * without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * This file is part of the Contiki operating system.
31  *
32  * @(#)$Id: elfloader-arch-otf.h,v 1.1 2009/07/11 14:18:50 ksb Exp $
33  */
34 /**
35  * \addtogroup elfloader
36  * @{
37  */
38 
39 /**
40  * \defgroup elfloaderarch Architecture specific functionality for the ELF loader.
41  *
42  * The architecture specific functionality for the Contiki ELF loader
43  * has to be implemented for each processor type Contiki runs on.
44  *
45  * Since the ELF format is slightly different for different processor
46  * types, the Contiki ELF loader is divided into two parts: the
47  * generic ELF loader module (\ref elfloader) and the architecture
48  * specific part (this module). The architecture specific part deals
49  * with memory allocation, code and data relocation, and writing the
50  * relocated ELF code into program memory.
51  *
52  * To port the Contiki ELF loader to a new processor type, this module
53  * has to be implemented for the new processor type.
54  *
55  * @{
56  */
57 
58 /**
59  * \file
60  * Header file for the architecture specific parts of the Contiki ELF loader.
61  *
62  * \author
63  * Adam Dunkels <adam@sics.se>
64  *
65  */
66 
67 #ifndef __ELFLOADER_ARCH_H__
68 #define __ELFLOADER_ARCH_H__
69 
70 #include "elfloader-otf.h"
71 
72 
73 /**
74  * \brief Perform a relocation.
75  * \param output The output object for the segment.
76  * \param sectionoffset The file offset at which the relocation can be found.
77  * \param sectionaddr The section start address (absolute runtime).
78  * \param rela A pointer to an ELF32 rela structure (struct elf32_rela).
79  * \param addr The relocated address.
80  *
81  * This function is called from the Contiki ELF loader to
82  * perform a relocation on a piece of code or data. The
83  * relocated address is calculated by the Contiki ELF
84  * loader, based on information in the ELF file, and it is
85  * the responsibility of this function to patch the
86  * executable code. The Contiki ELF loader passes a
87  * pointer to an ELF32 rela structure (struct elf32_rela)
88  * that contains information about how to patch the
89  * code. This information is different from processor to
90  * processor.
91  */
92 int elfloader_arch_relocate(int input_fd,
93  struct elfloader_output *output,
94  unsigned int sectionoffset,
95  char *sectionaddr,
96  struct elf32_rela *rela, char *addr);
97 
98 #endif /* __ELFLOADER_ARCH_H__ */
99 
100 /** @} */
101 /** @} */