Contiki 3.x
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  */
33 /**
34  * \addtogroup elfloader
35  * @{
36  */
37 
38 /**
39  * \defgroup elfloaderarch Architecture specific functionality for the ELF loader.
40  *
41  * The architecture specific functionality for the Contiki ELF loader
42  * has to be implemented for each processor type Contiki runs on.
43  *
44  * Since the ELF format is slightly different for different processor
45  * types, the Contiki ELF loader is divided into two parts: the
46  * generic ELF loader module (\ref elfloader) and the architecture
47  * specific part (this module). The architecture specific part deals
48  * with memory allocation, code and data relocation, and writing the
49  * relocated ELF code into program memory.
50  *
51  * To port the Contiki ELF loader to a new processor type, this module
52  * has to be implemented for the new processor type.
53  *
54  * @{
55  */
56 
57 /**
58  * \file
59  * Header file for the architecture specific parts of the Contiki ELF loader.
60  *
61  * \author
62  * Adam Dunkels <adam@sics.se>
63  *
64  */
65 
66 #ifndef ELFLOADER_ARCH_H_
67 #define ELFLOADER_ARCH_H_
68 
69 #include "elfloader-otf.h"
70 
71 
72 /**
73  * \brief Perform a relocation.
74  * \param output The output object for the segment.
75  * \param sectionoffset The file offset at which the relocation can be found.
76  * \param sectionaddr The section start address (absolute runtime).
77  * \param rela A pointer to an ELF32 rela structure (struct elf32_rela).
78  * \param addr The relocated address.
79  *
80  * This function is called from the Contiki ELF loader to
81  * perform a relocation on a piece of code or data. The
82  * relocated address is calculated by the Contiki ELF
83  * loader, based on information in the ELF file, and it is
84  * the responsibility of this function to patch the
85  * executable code. The Contiki ELF loader passes a
86  * pointer to an ELF32 rela structure (struct elf32_rela)
87  * that contains information about how to patch the
88  * code. This information is different from processor to
89  * processor.
90  */
91 int elfloader_arch_relocate(int input_fd,
92  struct elfloader_output *output,
93  unsigned int sectionoffset,
94  char *sectionaddr,
95  struct elf32_rela *rela, char *addr);
96 
97 #endif /* ELFLOADER_ARCH_H_ */
98 
99 /** @} */
100 /** @} */
void elfloader_arch_relocate(int fd, unsigned int sectionoffset, char *sectionaddr, struct elf32_rela *rela, char *addr)
Perform a relocation.
Header file for the Contiki ELF loader.
elfloader output object