⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 elf.h

📁 ecos实时嵌入式操作系统
💻 H
📖 第 1 页 / 共 3 页
字号:
#ifndef CYGONCE_LOADER_ELF_H#define CYGONCE_LOADER_ELF_H//==========================================================================////      elf.h////      ELF file format definitions////==========================================================================//####ECOSGPLCOPYRIGHTBEGIN####// -------------------------------------------// This file is part of eCos, the Embedded Configurable Operating System.// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.//// eCos is free software; you can redistribute it and/or modify it under// the terms of the GNU General Public License as published by the Free// Software Foundation; either version 2 or (at your option) any later version.//// eCos is distributed in the hope that it will be useful, but WITHOUT ANY// WARRANTY; without even the implied warranty of MERCHANTABILITY or// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License// for more details.//// You should have received a copy of the GNU General Public License along// with eCos; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.//// As a special exception, if other files instantiate templates or use macros// or inline functions from this file, or you compile this file and link it// with other works to produce a work based on this file, this file does not// by itself cause the resulting work to be covered by the GNU General Public// License. However the source code for this file must still be made available// in accordance with section (3) of the GNU General Public License.//// This exception does not invalidate any other reasons why a work based on// this file might be covered by the GNU General Public License.//// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.// at http://sources.redhat.com/ecos/ecos-license/// -------------------------------------------//####ECOSGPLCOPYRIGHTEND####//==========================================================================//#####DESCRIPTIONBEGIN####//// Author(s):           nickg// Contributors:        nickg// Date:                2000-11-15// Purpose:             Define ELF file format// Description:         The types defined here describe the ELF file format.//              // Usage:       #include <cyg/loader/elf.h>////####DESCRIPTIONEND####////==========================================================================//// Quite a lot of this file was taken from the BSD exec_elf.h header file.// Hence we should show you this...///*      $OpenBSD: exec_elf.h,v 1.20 1999/09/19 16:16:49 kstailey Exp $  *//* * Copyright (c) 1995, 1996 Erik Theisen.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products *    derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *///==========================================================================#include <cyg/infra/cyg_type.h>// -------------------------------------------------------------------------// Basic types:typedef cyg_uint32 Elf32_Addr;typedef cyg_uint32 Elf32_Off;typedef cyg_uint16 Elf32_Half;typedef cyg_uint32 Elf32_Word;typedef cyg_int32  Elf32_Sword;typedef cyg_uint64 Elf64_Addr;typedef cyg_uint64 Elf64_Off;typedef cyg_uint16 Elf64_Half;typedef cyg_uint32 Elf64_Word;typedef cyg_int32  Elf64_Sword;typedef cyg_uint64 Elf64_Xword;typedef cyg_int64  Elf64_Sxword;// -------------------------------------------------------------------------// ELF header#define EI_NIDENT 16typedef struct {    unsigned char   e_ident[EI_NIDENT];    Elf32_Half      e_type;    Elf32_Half      e_machine;    Elf32_Word      e_version;    Elf32_Addr      e_entry;    Elf32_Off       e_phoff;    Elf32_Off       e_shoff;    Elf32_Word      e_flags;    Elf32_Half      e_ehsize;    Elf32_Half      e_phentsize;    Elf32_Half      e_phnum;    Elf32_Half      e_shentsize;    Elf32_Half      e_shnum;    Elf32_Half      e_shtrndx;} Elf32_Ehdr;typedef struct {    unsigned char   e_ident[EI_NIDENT];    Elf64_Half      e_type;    Elf64_Half      e_machine;    Elf64_Word      e_version;    Elf64_Addr      e_entry;    Elf64_Off       e_phoff;    Elf64_Off       e_shoff;    Elf64_Word      e_flags;    Elf64_Half      e_ehsize;    Elf64_Half      e_phentsize;    Elf64_Half      e_phnum;    Elf64_Half      e_shentsize;    Elf64_Half      e_shnum;    Elf64_Half      e_shtrndx;} Elf64_Ehdr;// -------------------------------------------------------------------------/* e_ident[] identification indexes */#define EI_MAG0         0               /* file ID */#define EI_MAG1         1               /* file ID */#define EI_MAG2         2               /* file ID */#define EI_MAG3         3               /* file ID */#define EI_CLASS        4               /* file class */#define EI_DATA         5               /* data encoding */#define EI_VERSION      6               /* ELF header version */#define EI_OSABI        7               /* Operating system/ABI identification */#define EI_ABIVERSION   8               /* ABI version */#define EI_PAD          9               /* start of pad bytes */// -------------------------------------------------------------------------/* e_ident[] magic number */#define ELFMAG0         0x7f            /* e_ident[EI_MAG0] */#define ELFMAG1         'E'             /* e_ident[EI_MAG1] */#define ELFMAG2         'L'             /* e_ident[EI_MAG2] */#define ELFMAG3         'F'             /* e_ident[EI_MAG3] */#define ELFMAG          "\177ELF"       /* magic */#define SELFMAG         4               /* size of magic */// -------------------------------------------------------------------------/* e_ident[] file class */#define ELFCLASSNONE    0               /* invalid */#define ELFCLASS32      1               /* 32-bit objs */#define ELFCLASS64      2               /* 64-bit objs */#define ELFCLASSNUM     3               /* number of classes */// -------------------------------------------------------------------------/* e_ident[] data encoding */#define ELFDATANONE     0               /* invalid */#define ELFDATA2LSB     1               /* Little-Endian */#define ELFDATA2MSB     2               /* Big-Endian */#define ELFDATANUM      3               /* number of data encode defines */// -------------------------------------------------------------------------/* e_ident */#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \                      (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \                      (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \                      (ehdr).e_ident[EI_MAG3] == ELFMAG3)// -------------------------------------------------------------------------/* e_type */#define ET_NONE         0               /* No file type */#define ET_REL          1               /* relocatable file */#define ET_EXEC         2               /* executable file */#define ET_DYN          3               /* shared object file */#define ET_CORE         4               /* core file */#define ET_NUM          5               /* number of types */#define ET_LOOS         0xfe00          /* Operating system-specific */#define ET_HIOS         0xfeff          /* Operating system-specific */#define ET_LOPROC       0xff00          /* reserved range for processor */#define ET_HIPROC       0xffff          /*  specific e_type */// -------------------------------------------------------------------------/* e_machine */// The following values taken from 22 June 2000 SysV ABI spec, updated with// extra values from binutils elf/common.h.#define EM_NONE                 0       // No machine#define EM_M32                  1       // AT&T WE 32100#define EM_SPARC                2       // SPARC#define EM_386                  3       // Intel 80386#define EM_68K                  4       // Motorola 68000#define EM_88K                  5       // Motorola 88000#define EM_860                  7       // Intel 80860#define EM_MIPS                 8       // MIPS I Architecture#define EM_S370                 9       // IBM System/370 Processor#define EM_MIPS_RS3_LE          10      // MIPS RS3000 Little-endian#define EM_PARISC               15      // Hewlett-Packard PA-RISC#define EM_VPP500               17      // Fujitsu VPP500#define EM_SPARC32PLUS          18      // Enhanced instruction set SPARC#define EM_960                  19      // Intel 80960#define EM_PPC                  20      // PowerPC#define EM_PPC64                21      // 64-bit PowerPC#define EM_V800                 36      // NEC V800#define EM_FR20                 37      // Fujitsu FR20#define EM_RH32                 38      // TRW RH-32#define EM_RCE                  39      // Motorola RCE#define EM_ARM                  40      // Advanced RISC Machines ARM#define EM_ALPHA                41      // Digital Alpha

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -