/* This file defines standard ELF types, structures, and macros. Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ian Lance Taylor <ian@cygnus.com>. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _ELF_H #define _ELF_H
#include<stdint.h>
/* ELF defination file from GNU C Library. We simplefied this * file for our lab, removing definations about ELF64, structs and * enums which we don't care. */
/* Type for a 16-bit quantity. */ typedefuint16_t Elf32_Half;
/* Types for signed and unsigned 32-bit quantities. */ typedefuint32_t Elf32_Word; typedefint32_t Elf32_Sword;
/* Types for signed and unsigned 64-bit quantities. */ typedefuint64_t Elf32_Xword; typedefint64_t Elf32_Sxword;
/* Type of addresses. */ typedefuint32_t Elf32_Addr;
/* Type of file offsets. */ typedefuint32_t Elf32_Off;
/* Type for section indices, which are 16-bit quantities. */ typedefuint16_t Elf32_Section;
/* Type of symbol indices. */ typedefuint32_t Elf32_Symndx;
/* Lab 1 Key Code "readelf-struct-def" */
/* The ELF file header. This appears at the start of every ELF file. */
#define EI_NIDENT (16)
typedefstruct { unsignedchar e_ident[EI_NIDENT]; /* Magic number and other info */ Elf32_Half e_type; /* Object file type */ Elf32_Half e_machine; /* Architecture */ Elf32_Word e_version; /* Object file version */ Elf32_Addr e_entry; /* Entry point virtual address */ Elf32_Off e_phoff; /* Program header table file offset */ Elf32_Off e_shoff; /* Section header table file offset */ Elf32_Word e_flags; /* Processor-specific flags */ Elf32_Half e_ehsize; /* ELF header size in bytes */ Elf32_Half e_phentsize; /* Program header table entry size */ Elf32_Half e_phnum; /* Program header table entry count */ Elf32_Half e_shentsize; /* Section header table entry size */ Elf32_Half e_shnum; /* Section header table entry count */ Elf32_Half e_shstrndx; /* Section header string table index */ } Elf32_Ehdr;
/* Fields in the e_ident array. The EI_* macros are indices into the array. The macros under each EI_* macro are the values the byte may have. */
#define EI_MAG0 0 /* File identification byte 0 index */ #define ELFMAG0 0x7f /* Magic number byte 0 */
#define EI_MAG1 1 /* File identification byte 1 index */ #define ELFMAG1 'E'/* Magic number byte 1 */
#define EI_MAG2 2 /* File identification byte 2 index */ #define ELFMAG2 'L'/* Magic number byte 2 */
#define EI_MAG3 3 /* File identification byte 3 index */ #define ELFMAG3 'F'/* Magic number byte 3 */