From ce887d66a761c7b84ba8011d8bc47e3c83bb5488 Mon Sep 17 00:00:00 2001 From: pixel Date: Fri, 2 Dec 2005 11:28:26 +0000 Subject: Adding PSx-Patcher to the tree. --- includes/binary-elf.h | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 includes/binary-elf.h (limited to 'includes/binary-elf.h') diff --git a/includes/binary-elf.h b/includes/binary-elf.h new file mode 100644 index 0000000..f1ea14e --- /dev/null +++ b/includes/binary-elf.h @@ -0,0 +1,98 @@ +/* + * PSX-Tools Bundle Pack + * Copyright (C) 2002-2005 Nicolas "Pixel" Noble + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* $Id: binary-elf.h,v 1.1 2005-12-02 11:28:26 pixel Exp $ */ + +#ifndef __BINARY_ELF_H__ +#define __BINARY_ELF_H__ + +#ifdef _MSC_VER +//do packing +#endif + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef signed char s8; +typedef signed short s16; +typedef signed int s32; + +#define PROGBITS 1 +#define NOBITS 8 +#define REL 9 +#define NOTYPE 0 +#define SECTION 3 +#define PT_LOAD 1 +#define PF_X 1 +#define PF_W 2 +#define PF_R 4 + +struct elf_header_t { + union { + u8 raw[16]; + struct e_ident_t { + u8 ei_magic[4]; + u8 ei_class; + u8 ei_data; + u8 ei_version; + } cook; + } e_ident; + u16 e_type; + u16 e_machine; + u32 e_version; + u32 e_entry; + u32 e_phoff; + u32 e_shoff; + u32 e_flags; + u16 e_ehsize; + u16 e_phentsize; + u16 e_phnum; + u16 e_shentsize; + u16 e_shnum; + u16 e_shstrndx; +} PACKED; + +struct elf_pheader_t { + u32 type; /* == 1, PT_LOAD (that is, this section will get loaded */ + u32 offset; /* offset in file, on a 4096 bytes boundary */ + u32 vaddr; /* virtual address where this section is loaded */ + u32 paddr; /* physical address where this section is loaded */ + u32 filesz; /* size of that section in the file */ + u32 memsz; /* size of that section in memory (rest is zero filled) */ + u32 flags; /* PF_X | PF_W | PF_R, that is executable, writable, readable */ + u32 align; /* == 0x1000 that is 4096 bytes */ +} PACKED; + + +struct elf_section_t { + u32 sh_name, sh_type, sh_flags, sh_addr, sh_offset, sh_size; + u32 sh_link, sh_info, sh_addralign, sh_entsize; +} PACKED; + +struct elf_symbol_t { + u32 st_name, st_value, st_size; + u8 st_info, st_other; + u16 st_shndx; +} PACKED; + +struct elf_reloc_t { + u32 r_offset, r_info; +} PACKED; + +#endif -- cgit v1.2.3