~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to utils/fpcres/elfbfd.pas

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{$ifdef fpc}
 
2
{$mode objfpc}
 
3
{$endif}
 
4
{$H+}
 
5
unit elfbfd;
 
6
 
 
7
{ELF Binary Format Description. 32/64 bit definitions }
 
8
 
 
9
interface
 
10
 
 
11
const
 
12
  SHT_NULL     = 0;
 
13
  SHT_PROGBITS = 1;
 
14
  SHT_SYMTAB   = 2;
 
15
  SHT_STRTAB   = 3;
 
16
  SHT_RELA     = 4;
 
17
  SHT_HASH     = 5;
 
18
  SHT_DYNAMIC  = 6;
 
19
  SHT_NOTE     = 7;
 
20
  SHT_NOBITS   = 8;
 
21
  SHT_REL      = 9;
 
22
  SHT_SHLIB    = 10;
 
23
  SHT_DYNSYM   = 11;
 
24
  SHF_WRITE     = 1;
 
25
  SHF_ALLOC     = 2;
 
26
  SHF_EXECINSTR = 4;
 
27
 
 
28
  PT_NULL       = 0;
 
29
  PT_LOAD       = 1;
 
30
  PT_DYNAMIC    = 2;
 
31
  PT_INTERP     = 3;
 
32
  PT_NOTE       = 4;
 
33
  PT_SHLIB      = 5;
 
34
  PT_PHDR       = 6;
 
35
  PT_LOOS       = $60000000;
 
36
  PT_HIOS       = $6fffffff;
 
37
  PT_LOPROC     = $70000000;
 
38
  PT_HIPROC     = $7fffffff;
 
39
 
 
40
Type
 
41
  TElf32header = packed record
 
42
    magic0123: longint;
 
43
    file_class: byte;
 
44
    data_encoding: byte;
 
45
    file_version: byte;
 
46
    padding: array[$07..$0F] of byte;
 
47
    e_type: word;
 
48
    e_machine: word;
 
49
    e_version: longint;
 
50
    e_entry: longint; { entrypoint }
 
51
    e_phoff: longint; { program header offset }
 
52
    e_shoff: longint; { sections header offset }
 
53
    e_flags: longint;
 
54
    e_ehsize: word; { elf header size in bytes }
 
55
    e_phentsize: word; { size of an entry in the program header array }
 
56
    e_phnum: word; { 0..e_phnum-1 of entrys }
 
57
    e_shentsize: word; { size of an entry in sections header array }
 
58
    e_shnum: word; { 0..e_shnum-1 of entrys }
 
59
    e_shstrndx: word; { index of string section header }
 
60
  end;
 
61
 
 
62
  TElf64header = packed record
 
63
    magic0123: longint;
 
64
    file_class: byte;
 
65
    data_encoding: byte;
 
66
    file_version: byte;
 
67
    padding: array[$07..$0F] of byte;
 
68
    e_type: word;
 
69
    e_machine: word;
 
70
    e_version: longint;
 
71
    e_entry: int64; { entrypoint }
 
72
    e_phoff: int64; { program header offset }
 
73
    e_shoff: int64; { sections header offset }
 
74
    e_flags: longint;
 
75
    e_ehsize: word; { elf header size in bytes }
 
76
    e_phentsize: word; { size of an entry in the program header array }
 
77
    e_phnum: word; { 0..e_phnum-1 of entrys }
 
78
    e_shentsize: word; { size of an entry in sections header array }
 
79
    e_shnum: word; { 0..e_shnum-1 of entrys }
 
80
    e_shstrndx: word; { index of string section header }
 
81
  end;
 
82
 
 
83
  TElf32sechdr = packed record
 
84
    sh_name: longint;
 
85
    sh_type: longint;
 
86
    sh_flags: longint;
 
87
    sh_addr: longint;
 
88
    sh_offset: longint;
 
89
    sh_size: longint;
 
90
    sh_link: longint;
 
91
    sh_info: longint;
 
92
    sh_addralign: longint;
 
93
    sh_entsize: longint;
 
94
  end;
 
95
 
 
96
  TElf64sechdr = packed record
 
97
    sh_name: longint;
 
98
    sh_type: longint;
 
99
    sh_flags: longint;
 
100
    sh_addr: int64;
 
101
    sh_offset: int64;
 
102
    sh_size: int64;
 
103
    sh_link: longint;
 
104
    sh_info: longint;
 
105
    sh_addralign: int64;
 
106
    sh_entsize: int64;
 
107
  end;
 
108
  
 
109
  { FPC resources }
 
110
  
 
111
  TELF32ResourceSectionInfo = packed record
 
112
    ptr: longint;
 
113
    size: longint;
 
114
  end;
 
115
 
 
116
  TELF64ResourceSectionInfo = packed record
 
117
    ptr: int64;
 
118
    size: int64;
 
119
  end;
 
120
 
 
121
  TELF32ResourceInfo = packed record
 
122
    reshash: longint; // always 32bit, contains an ELF hash of the resource entries name
 
123
    restype: longint; // always 32bit, contains the resource type ID compatible with Windows RES IDs
 
124
    ptr:     longint; // Byte offset to the resource inside the resdata section.
 
125
    name:    longint; // Byte offset to the the resource name inside the ressym section.
 
126
    size:    longint; // The size of the resource entry
 
127
  end;
 
128
 
 
129
  TELF64ResourceInfo = packed record
 
130
    reshash: longint; // always 32bit, contains an ELF hash of the resource entries name
 
131
    restype: longint; // always 32bit, contains the resource type ID compatible with Windows RES IDs
 
132
    ptr:     int64;   // Byte offset to the resource inside the resdata section.
 
133
    name:    int64;   // Byte offset to the the resource name inside the ressym section.
 
134
    size:    int64;   // The size of the resource entry
 
135
  end;
 
136
 
 
137
  TELF32ResourceSectionTable = packed record
 
138
    version: integer;
 
139
    resentries: integer;
 
140
    ressym: TELF32ResourceSectionInfo;
 
141
    reshash: TELF32ResourceSectionInfo;
 
142
    resdata: TELF32ResourceSectionInfo;
 
143
    resspare: TELF32ResourceSectionInfo;
 
144
    resstr: TELF32ResourceSectionInfo;
 
145
  end;
 
146
 
 
147
implementation
 
148
 
 
149
end.
 
150