ps2sdk
1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/fcntl.h>
#include <sys/unistd.h>
#include <erl.h>
#include <hashtab.h>
#include <recycle.h>
#include <tamtypes.h>
#include <kernel.h>
Go to the source code of this file.
Data Structures | |
struct | elf_header_t |
struct | elf_section_t |
struct | elf_symbol_t |
struct | elf_reloc_t |
struct | loosy_t |
struct | dependancy_t |
Macros | |
#define | DEBUG 1 |
#define | STANDALONE 1 |
#define | FORCE_ALIGN 1 |
#define | dprintf(a...) |
#define | rprintf(a...) |
#define | REL_TYPE 1 |
#define | PROGBITS 1 |
#define | NOBITS 8 |
#define | REL 9 |
#define | GLOBAL 1 |
#define | WEAK 2 |
#define | NOTYPE 0 |
#define | OBJECT 1 |
#define | FUNC 2 |
#define | SECTION 3 |
#define | R_MIPS_32 2 |
#define | R_MIPS_26 4 |
#define | R_MIPS_HI16 5 |
#define | R_MIPS_LO16 6 |
#define | free_and_return(code) |
#define | O_BINARY 0 |
Typedefs | |
typedef int(* | func_t) (void) |
typedef int(* | start_t) (int argc, char **argv) |
Functions | |
static u32 | align (u32 x, int align) |
static struct loosy_t * | create_loosy (struct erl_record_t *erl, u8 *reloc, int type) |
static void | destroy_loosy (struct loosy_t *l) |
static void | r_destroy_loosy (struct loosy_t *l) |
static struct symbol_t * | create_symbol (struct erl_record_t *provider, u32 address) |
static void | destroy_symbol (struct symbol_t *s) |
static struct erl_record_t * | allocate_erl_record () |
static void | destroy_erl_record (struct erl_record_t *erl) |
static int | apply_reloc (u8 *reloc, int type, u32 addr) |
struct symbol_t * | erl_find_local_symbol (const char *symbol, struct erl_record_t *erl) |
static struct symbol_t * | r_find_symbol (const char *symbol, struct erl_record_t *erl) |
struct symbol_t * | erl_find_symbol (const char *symbol) |
static struct dependancy_t * | add_dependancy (struct erl_record_t *depender, struct erl_record_t *provider) |
static void | destroy_dependancy (struct dependancy_t *d) |
static void | r_destroy_dependancy_r (struct erl_record_t *erl, struct dependancy_t *d) |
static void | destroy_dependancy_r (struct erl_record_t *erl) |
static void | add_loosy (struct erl_record_t *erl, u8 *reloc, int type, const char *symbol) |
static int | fix_loosy (struct erl_record_t *provider, const char *symbol, u32 address) |
static int | is_local (const char *symbol) |
static int | add_symbol (struct erl_record_t *erl, const char *symbol, u32 address) |
int | erl_add_global_symbol (const char *symbol, u32 address) |
static int | read_erl (int elf_handle, u8 *elf_mem, u32 addr, struct erl_record_t **p_erl_record) |
static struct erl_record_t * | _init_load_erl_wrapper_from_file (char *erl_id) |
static struct erl_record_t * | load_erl (const char *fname, u8 *elf_mem, u32 addr, int argc, char **argv) |
struct erl_record_t * | _init_load_erl_from_file (const char *fname, char *erl_id) |
struct erl_record_t * | load_erl_from_file (const char *fname, int argc, char **argv) |
struct erl_record_t * | load_erl_from_mem (u8 *mem, int argc, char **argv) |
struct erl_record_t * | load_erl_from_mem_to_addr (u8 *mem, u32 addr, int argc, char **argv) |
struct erl_record_t * | load_erl_from_file_to_addr (const char *fname, u32 addr, int argc, char **argv) |
struct erl_record_t * | _init_load_erl_from_file_to_addr (const char *fname, u32 addr, char *erl_id) |
void | r_unload_dependancies (char **d) |
int | unload_erl (struct erl_record_t *erl) |
struct erl_record_t * | erl_resolve (u32 address) |
struct erl_record_t * | find_erl (const char *name) |
void | erl_flush_symbols (struct erl_record_t *erl) |
Variables | |
static const char * | local_names [] |
static struct erl_record_t * | erl_record_root = 0 |
static htab * | global_symbols = 0 |
static htab * | loosy_relocs = 0 |
char | _init_erl_prefix [256] = "" |
static struct dependancy_t * | dependancy_root = 0 |
static reroot * | symbol_recycle = 0 |
erl_loader_t | _init_load_erl = _init_load_erl_wrapper_from_file |
The relocatable elf loader/linker.
Definition in file erl.c.
#define free_and_return | ( | code | ) |
struct erl_record_t* _init_load_erl_from_file | ( | const char * | fname, |
char * | erl_id | ||
) |
Definition at line 1012 of file erl.c.
References _init_erl_prefix, erl_id, find_erl(), and load_erl_from_file().
Referenced by _init_load_erl_wrapper_from_file(), and main().
struct erl_record_t* _init_load_erl_from_file_to_addr | ( | const char * | fname, |
u32 | addr, | ||
char * | erl_id | ||
) |
Definition at line 1055 of file erl.c.
References _init_erl_prefix, erl_id, find_erl(), and load_erl_from_file_to_addr().
|
static |
Definition at line 931 of file erl.c.
References _init_load_erl_from_file(), and erl_id.
|
static |
Definition at line 450 of file erl.c.
References dependancy_root, dependancy_t::depender, dependancy_t::next, dependancy_t::prev, and dependancy_t::provider.
Referenced by fix_loosy(), and read_erl().
|
static |
Definition at line 499 of file erl.c.
References create_loosy(), loosy_t::erl, hadd(), hcreate(), hkey, hstuff, loosy_relocs, loosy_t::next, loosy_t::reloc, and loosy_t::type.
Referenced by read_erl().
|
static |
Definition at line 546 of file erl.c.
References create_symbol(), dprintf, loosy_t::erl, erl_find_symbol(), fix_loosy(), FlushCache(), global_symbols, hadd(), hcreate(), is_local(), and erl_loader_t::symbols.
Referenced by erl_add_global_symbol(), and read_erl().
|
static |
Definition at line 349 of file erl.c.
References erl_loader_t::bytes, erl_record_root, erl_loader_t::flags, hcreate(), erl_loader_t::next, NULL, erl_loader_t::prev, and erl_loader_t::symbols.
Referenced by read_erl().
Definition at line 392 of file erl.c.
References dprintf, R_MIPS_26, R_MIPS_32, R_MIPS_HI16, and R_MIPS_LO16.
Referenced by fix_loosy(), and read_erl().
|
static |
Definition at line 302 of file erl.c.
References loosy_t::erl, loosy_t::next, loosy_t::reloc, and loosy_t::type.
Referenced by add_loosy().
|
static |
Definition at line 331 of file erl.c.
References symbol_t::address, symbol_t::provider, remkroot(), renew, and symbol_recycle.
Referenced by add_symbol().
|
static |
Definition at line 471 of file erl.c.
References dependancy_root, dependancy_t::next, and dependancy_t::prev.
Referenced by r_destroy_dependancy_r().
|
static |
Definition at line 495 of file erl.c.
References dependancy_root, and r_destroy_dependancy_r().
Referenced by unload_erl().
|
static |
Definition at line 368 of file erl.c.
References erl_loader_t::bytes, ERL_FLAG_CLEAR, ERL_FLAG_STATIC, erl_flush_symbols(), erl_record_root, erl_loader_t::flags, erl_loader_t::fullsize, erl_loader_t::next, and erl_loader_t::prev.
Referenced by unload_erl().
|
static |
|
static |
Definition at line 345 of file erl.c.
References redel, s, and symbol_recycle.
Referenced by erl_flush_symbols().
int erl_add_global_symbol | ( | const char * | symbol, |
u32 | address | ||
) |
Definition at line 574 of file erl.c.
References add_symbol().
Referenced by export_symbols().
struct symbol_t* erl_find_local_symbol | ( | const char * | symbol, |
struct erl_record_t * | erl | ||
) |
Definition at line 427 of file erl.c.
References hfind(), hstuff, and erl_loader_t::symbols.
Referenced by load_erl(), and unload_erl().
struct symbol_t* erl_find_symbol | ( | const char * | symbol | ) |
Definition at line 443 of file erl.c.
References erl_record_root, global_symbols, hfind(), hstuff, and r_find_symbol().
Referenced by add_symbol(), main(), and read_erl().
void erl_flush_symbols | ( | struct erl_record_t * | erl | ) |
Definition at line 1145 of file erl.c.
References destroy_symbol(), hcount, hdel(), hdestroy(), hfirst(), hkey, hstuff, and erl_loader_t::symbols.
Referenced by destroy_erl_record(), and unload_erl().
struct erl_record_t* erl_resolve | ( | u32 | address | ) |
Definition at line 1121 of file erl.c.
References erl_loader_t::bytes, erl_record_root, erl_loader_t::fullsize, and erl_loader_t::next.
struct erl_record_t* find_erl | ( | const char * | name | ) |
Definition at line 1133 of file erl.c.
References erl_record_root, erl_loader_t::name, and erl_loader_t::next.
Referenced by _init_load_erl_from_file(), _init_load_erl_from_file_to_addr(), and r_unload_dependancies().
|
static |
Definition at line 515 of file erl.c.
References add_dependancy(), apply_reloc(), loosy_t::erl, hdel(), hfind(), hkey, hstuff, loosy_relocs, loosy_t::next, r_destroy_loosy(), loosy_t::reloc, and loosy_t::type.
Referenced by add_symbol().
|
static |
|
static |
Definition at line 940 of file erl.c.
References _init_load_erl, erl_loader_t::dependancies, dprintf, erl_find_local_symbol(), erl_loader_t::name, O_BINARY, read_erl(), s, and unload_erl().
Referenced by load_erl_from_file(), load_erl_from_file_to_addr(), load_erl_from_mem(), and load_erl_from_mem_to_addr().
struct erl_record_t* load_erl_from_file | ( | const char * | fname, |
int | argc, | ||
char ** | argv | ||
) |
Definition at line 1030 of file erl.c.
References ERL_DYN_ADDR, and load_erl().
Referenced by _init_load_erl_from_file().
struct erl_record_t* load_erl_from_file_to_addr | ( | const char * | fname, |
u32 | addr, | ||
int | argc, | ||
char ** | argv | ||
) |
Definition at line 1048 of file erl.c.
References load_erl().
Referenced by _init_load_erl_from_file_to_addr().
struct erl_record_t* load_erl_from_mem | ( | u8 * | mem, |
int | argc, | ||
char ** | argv | ||
) |
Definition at line 1034 of file erl.c.
References ERL_DYN_ADDR, and load_erl().
struct erl_record_t* load_erl_from_mem_to_addr | ( | u8 * | mem, |
u32 | addr, | ||
int | argc, | ||
char ** | argv | ||
) |
Definition at line 1041 of file erl.c.
References load_erl().
|
static |
Definition at line 483 of file erl.c.
References dependancy_t::depender, destroy_dependancy(), and dependancy_t::next.
Referenced by destroy_dependancy_r().
|
static |
Definition at line 320 of file erl.c.
References destroy_loosy(), and loosy_t::next.
Referenced by fix_loosy().
|
static |
Definition at line 435 of file erl.c.
References hfind(), hstuff, erl_loader_t::next, and erl_loader_t::symbols.
Referenced by erl_find_symbol().
void r_unload_dependancies | ( | char ** | d | ) |
Definition at line 1073 of file erl.c.
References find_erl(), and unload_erl().
Referenced by unload_erl().
|
static |
Definition at line 578 of file erl.c.
References add_dependancy(), add_loosy(), add_symbol(), align(), allocate_erl_record(), apply_reloc(), erl_loader_t::bytes, elf_header_t::cook, dprintf, elf_header_t::e_ehsize, elf_header_t::e_entry, elf_header_t::e_flags, elf_header_t::e_ident, elf_header_t::e_machine, elf_header_t::e_phentsize, elf_header_t::e_phnum, elf_header_t::e_phoff, elf_header_t::e_shentsize, elf_header_t::e_shnum, elf_header_t::e_shoff, elf_header_t::e_shstrndx, elf_header_t::e_type, elf_header_t::e_version, ERL_DYN_ADDR, erl_find_symbol(), ERL_FLAG_STATIC, erl_loader_t::flags, FlushCache(), free_and_return, erl_loader_t::fullsize, FUNC, GLOBAL, NOBITS, NOTYPE, OBJECT, PROGBITS, elf_reloc_t::r_info, elf_reloc_t::r_offset, REL, REL_TYPE, rprintf, s, SECTION, elf_section_t::sh_addr, elf_section_t::sh_addralign, elf_section_t::sh_entsize, elf_section_t::sh_flags, elf_section_t::sh_info, elf_section_t::sh_link, elf_section_t::sh_name, elf_section_t::sh_offset, elf_section_t::sh_size, elf_section_t::sh_type, elf_symbol_t::st_name, elf_symbol_t::st_shndx, elf_symbol_t::st_value, and WEAK.
Referenced by load_erl().
int unload_erl | ( | struct erl_record_t * | erl | ) |
Definition at line 1084 of file erl.c.
References erl_loader_t::dependancies, dependancy_root, destroy_dependancy_r(), destroy_erl_record(), dprintf, erl_find_local_symbol(), ERL_FLAG_STICKY, erl_flush_symbols(), erl_loader_t::flags, erl_loader_t::name, dependancy_t::next, dependancy_t::provider, r_unload_dependancies(), and s.
Referenced by load_erl(), and r_unload_dependancies().
char _init_erl_prefix[256] = "" |
Definition at line 281 of file erl.c.
Referenced by _init_load_erl_from_file(), _init_load_erl_from_file_to_addr(), and parse_boot_path().
erl_loader_t _init_load_erl = _init_load_erl_wrapper_from_file |
Definition at line 938 of file erl.c.
Referenced by load_erl().
|
static |
Definition at line 283 of file erl.c.
Referenced by add_dependancy(), destroy_dependancy(), destroy_dependancy_r(), and unload_erl().
|
static |
Definition at line 276 of file erl.c.
Referenced by allocate_erl_record(), destroy_erl_record(), erl_find_symbol(), erl_resolve(), and find_erl().
|
static |
Definition at line 278 of file erl.c.
Referenced by add_symbol(), and erl_find_symbol().
|
static |
Definition at line 205 of file erl.c.
Referenced by is_local().
|
static |
Definition at line 279 of file erl.c.
Referenced by add_loosy(), and fix_loosy().
|
static |
Definition at line 329 of file erl.c.
Referenced by create_symbol(), and destroy_symbol().