00001 /* 00002 * Copyright (c) 2005, Swedish Institute of Computer Science 00003 * Copyright (c) 2007, Simon Berg 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 1. Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * 3. Neither the name of the Institute nor the names of its contributors 00015 * may be used to endorse or promote products derived from this software 00016 * without specific prior written permission. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 00019 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00021 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 00022 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00023 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00024 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00025 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00026 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00027 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00028 * SUCH DAMAGE. 00029 * 00030 * This file is part of the Contiki operating system. 00031 * 00032 * @(#)$Id: elfloader-arch-otf.h,v 1.1 2009/07/11 14:18:50 ksb Exp $ 00033 */ 00034 /** 00035 * \addtogroup elfloader 00036 * @{ 00037 */ 00038 00039 /** 00040 * \defgroup elfloaderarch Architecture specific functionality for the ELF loader. 00041 * 00042 * The architecture specific functionality for the Contiki ELF loader 00043 * has to be implemented for each processor type Contiki runs on. 00044 * 00045 * Since the ELF format is slightly different for different processor 00046 * types, the Contiki ELF loader is divided into two parts: the 00047 * generic ELF loader module (\ref elfloader) and the architecture 00048 * specific part (this module). The architecture specific part deals 00049 * with memory allocation, code and data relocation, and writing the 00050 * relocated ELF code into program memory. 00051 * 00052 * To port the Contiki ELF loader to a new processor type, this module 00053 * has to be implemented for the new processor type. 00054 * 00055 * @{ 00056 */ 00057 00058 /** 00059 * \file 00060 * Header file for the architecture specific parts of the Contiki ELF loader. 00061 * 00062 * \author 00063 * Adam Dunkels <adam@sics.se> 00064 * 00065 */ 00066 00067 #ifndef __ELFLOADER_ARCH_H__ 00068 #define __ELFLOADER_ARCH_H__ 00069 00070 #include "elfloader-otf.h" 00071 00072 00073 /** 00074 * \brief Perform a relocation. 00075 * \param output The output object for the segment. 00076 * \param sectionoffset The file offset at which the relocation can be found. 00077 * \param sectionaddr The section start address (absolute runtime). 00078 * \param rela A pointer to an ELF32 rela structure (struct elf32_rela). 00079 * \param addr The relocated address. 00080 * 00081 * This function is called from the Contiki ELF loader to 00082 * perform a relocation on a piece of code or data. The 00083 * relocated address is calculated by the Contiki ELF 00084 * loader, based on information in the ELF file, and it is 00085 * the responsibility of this function to patch the 00086 * executable code. The Contiki ELF loader passes a 00087 * pointer to an ELF32 rela structure (struct elf32_rela) 00088 * that contains information about how to patch the 00089 * code. This information is different from processor to 00090 * processor. 00091 */ 00092 int elfloader_arch_relocate(int input_fd, 00093 struct elfloader_output *output, 00094 unsigned int sectionoffset, 00095 char *sectionaddr, 00096 struct elf32_rela *rela, char *addr); 00097 00098 #endif /* __ELFLOADER_ARCH_H__ */ 00099 00100 /** @} */ 00101 /** @} */