~ubuntu-branches/ubuntu/wily/slof/wily

« back to all changes in this revision

Viewing changes to include/libelf.h

  • Committer: Package Import Robot
  • Author(s): Aurelien Jarno
  • Date: 2012-09-16 23:05:23 UTC
  • Revision ID: package-import@ubuntu.com-20120916230523-r2ynulqmp2tyu2e5
Tags: upstream-20120217+dfsg
ImportĀ upstreamĀ versionĀ 20120217+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * Copyright (c) 2004, 2011 IBM Corporation
 
3
 * All rights reserved.
 
4
 * This program and the accompanying materials
 
5
 * are made available under the terms of the BSD License
 
6
 * which accompanies this distribution, and is available at
 
7
 * http://www.opensource.org/licenses/bsd-license.php
 
8
 *
 
9
 * Contributors:
 
10
 *     IBM Corporation - initial implementation
 
11
 *****************************************************************************/
 
12
 
 
13
/*
 
14
 * ELF loader library
 
15
 */
 
16
 
 
17
#ifndef __LIBELF_H
 
18
#define __LIBELF_H
 
19
 
 
20
#include <stdint.h>
 
21
 
 
22
/* ELF object file types */
 
23
#define ET_NONE         0       /* No file type */
 
24
#define ET_REL          1       /* Relocatable file */
 
25
#define ET_EXEC         2       /* Executable file */
 
26
#define ET_DYN          3       /* Shared object file */
 
27
#define ET_CORE         4       /* Core file */
 
28
 
 
29
/* Generic ELF header */
 
30
struct ehdr {
 
31
        uint32_t ei_ident;
 
32
        uint8_t ei_class;
 
33
        uint8_t ei_data;
 
34
        uint8_t ei_version;
 
35
        uint8_t ei_pad[9];
 
36
        uint16_t e_type;
 
37
        uint16_t e_machine;
 
38
        uint32_t e_version;
 
39
};
 
40
 
 
41
/* Section types (sh_type) */
 
42
#define SHT_NULL        0       /* Unused section header */
 
43
#define SHT_PROGBITS    1       /* Information defined by the program */
 
44
#define SHT_SYMTAB      2       /* Linker symbol table */
 
45
#define SHT_STRTAB      3       /* String table */
 
46
#define SHT_RELA        4       /* "Rela" type relocation entries */
 
47
#define SHT_HASH        5       /* Symbol hash table */
 
48
#define SHT_DYNAMIC     6       /* Dynamic linking tables */
 
49
#define SHT_NOTE        7       /* Note information */
 
50
#define SHT_NOBITS      8       /* Uninitialized space */
 
51
#define SHT_REL         9       /* "Rel" type relocation entries */
 
52
#define SHT_SHLIB       10      /* Reserved */
 
53
#define SHT_DYNSYM      11      /* Dynamic loader symbol table */
 
54
 
 
55
/* Section attributs (sh_flags) */
 
56
#define SHF_WRITE       0x1
 
57
#define SHF_ALLOC       0x2
 
58
#define SHF_EXECINSTR   0x4
 
59
 
 
60
/* Segment types (p_type) */
 
61
#define PT_NULL         0       /* Unused entry */
 
62
#define PT_LOAD         1       /* Loadable segment */
 
63
#define PT_DYNAMIC      2       /* Dynamic linking tables */
 
64
#define PT_INTERP       3       /* Program interpreter path name */
 
65
#define PT_NOTE         4       /* Note sections */
 
66
 
 
67
 
 
68
int elf_load_file(void *file_addr, unsigned long *entry,
 
69
                  int (*pre_load)(void*, long),
 
70
                  void (*post_load)(void*, long));
 
71
int elf_load_file_to_addr(void *file_addr, void *addr, unsigned long *entry,
 
72
                          int (*pre_load)(void*, long),
 
73
                          void (*post_load)(void*, long));
 
74
 
 
75
unsigned int elf_load_segments32(void *file_addr, signed long offset,
 
76
                                 int (*pre_load)(void*, long),
 
77
                                 void (*post_load)(void*, long));
 
78
unsigned long elf_load_segments64(void *file_addr, signed long offset,
 
79
                                  int (*pre_load)(void*, long),
 
80
                                  void (*post_load)(void*, long));
 
81
 
 
82
long elf_get_base_addr(void *file_addr);
 
83
long elf_get_base_addr32(void *file_addr);
 
84
long elf_get_base_addr64(void *file_addr);
 
85
 
 
86
void elf_relocate64(void *file_addr, signed long offset);
 
87
 
 
88
int elf_forth_claim(void *addr, long size);
 
89
 
 
90
#endif                          /* __LIBELF_H */