Subversion Repositories QNX 8.QNX8 IFS tool

Rev

Rev 10 | Rev 16 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10 Rev 11
Line 125... Line 125...
125
 
125
 
126
 
126
 
127
// Executable and Linkable Format master header structure type definition
127
// Executable and Linkable Format master header structure type definition
128
typedef struct elf32_header_s
128
typedef struct elf32_header_s
129
{
129
{
130
   unsigned char magic[4];                     // offset 0: "\x07" + "ELF"
130
   unsigned char magic[4];                     // offset 0: "\x7f" + "ELF"
-
 
131
#pragma verify match_var_int("magic[0]", "0x7f")
-
 
132
#pragma verify match_var_int("magic[1]", "0x45")
-
 
133
#pragma verify match_var_int("magic[2]", "0x4c")
-
 
134
#pragma verify match_var_int("magic[3]", "0x46")
131
   unsigned char platform_size;                // offset 4: 1 = 32-bit, 2 = 64-bit
135
   unsigned char platform_size;                // offset 4: 1 = 32-bit, 2 = 64-bit
-
 
136
#pragma verify match_var_int("platform_size", "1")
132
   unsigned char endianness;                   // offset 5: 1 = little endian, 2 = big endian
137
   unsigned char endianness;                   // offset 5: 1 = little endian, 2 = big endian
133
   unsigned char header_version;               // offset 6: typically 1
138
   unsigned char header_version;               // offset 6: typically 1
134
   unsigned char os_abi;                       // offset 7: 0 = SysV, 1 = HP/UX, 2 = NetBSD, 3 = Linux, 4 = GNU/Hurd, 6 = Solaris, 7 = AIX, 8 = IRIX, 9 = FreeBSD, 10 = Tru64, 11 = Novell, 12 = OpenBSD, 13 = OpenVMS, 14 = NonStop kernel, 15 = AROS, 16 = FenixOS, 17 = Nuxi CloudABI, 18 = OpenVOS
139
   unsigned char os_abi;                       // offset 7: 0 = SysV, 1 = HP/UX, 2 = NetBSD, 3 = Linux, 4 = GNU/Hurd, 6 = Solaris, 7 = AIX, 8 = IRIX, 9 = FreeBSD, 10 = Tru64, 11 = Novell, 12 = OpenBSD, 13 = OpenVMS, 14 = NonStop kernel, 15 = AROS, 16 = FenixOS, 17 = Nuxi CloudABI, 18 = OpenVOS
135
   unsigned char spare[8];                     // offset 8: zeroes
140
   unsigned char spare[8];                     // offset 8: zeroes
136
   unsigned __int16 type;                        // offset 16: 1 = relocatable, 2 = executable, 3 = shared, 4 = core dump
141
   unsigned __int16 type;                        // offset 16: 1 = relocatable, 2 = executable, 3 = shared, 4 = core dump
137
   unsigned __int16 instruction_set;             // offset 18: 2 = Sparc, 3 = i386, 8 = MIPS, 20 = PowerPC, 40 = ARM, 42 = SuperH, 50 = IA-64, 62 = x86_64, 183 = AArch64, 243 = RISC-V
142
   unsigned __int16 instruction_set;             // offset 18: 2 = Sparc, 3 = i386, 8 = MIPS, 20 = PowerPC, 40 = ARM, 42 = SuperH, 50 = IA-64, 62 = x86_64, 183 = AArch64, 243 = RISC-V
138
   unsigned __int32 elf_version;                 // offset 20: typically 1
143
   unsigned __int32 elf_version;                 // offset 20: typically 1
139
   unsigned __int32 entrypoint_offset;           // offset 24: offset to program entrypoint
144
   unsigned __int32 entrypoint_offset;           // offset 24: offset to program entrypoint
140
   unsigned __int32 program_header_table_offset; // offset 28: offset to program header table
145
   unsigned __int32 program_header_table_offset; // offset 28: offset to program header table
Line 145... Line 150...
145
   unsigned __int16 program_header_table_len;    // offset 44: number of entries in the program header table
150
   unsigned __int16 program_header_table_len;    // offset 44: number of entries in the program header table
146
   unsigned __int16 section_header_item_size;    // offset 46: size of an entry in the section header table
151
   unsigned __int16 section_header_item_size;    // offset 46: size of an entry in the section header table
147
   unsigned __int16 section_header_table_len;    // offset 48: number of entries in the section header table
152
   unsigned __int16 section_header_table_len;    // offset 48: number of entries in the section header table
148
   unsigned __int16 section_header_names_idx;    // offset 50: index of the entry in the section header table that contains the section names
153
   unsigned __int16 section_header_names_idx;    // offset 50: index of the entry in the section header table that contains the section names
149
} elf32_header_t;
154
} elf32_header_t;
150
 
155
 
151
typedef struct elf64_header_s
156
typedef struct elf64_header_s
152
      {
157
{
153
         unsigned char magic[4];                     // offset 0: "\x07" + "ELF"
158
   unsigned char magic[4];                     // offset 0: "\x07" + "ELF"
-
 
159
#pragma verify match_var_int("magic[0]", "0x7f")
-
 
160
#pragma verify match_var_int("magic[1]", "0x45")
-
 
161
#pragma verify match_var_int("magic[2]", "0x4c")
-
 
162
#pragma verify match_var_int("magic[3]", "0x46")
154
         unsigned char platform_size;                // offset 4: 1 = 32-bit, 2 = 64-bit
163
   unsigned char platform_size;                // offset 4: 1 = 32-bit, 2 = 64-bit
-
 
164
#pragma verify match_var_int("platform_size", "2")
155
         unsigned char endianness;                   // offset 5: 1 = little endian, 2 = big endian
165
   unsigned char endianness;                   // offset 5: 1 = little endian, 2 = big endian
156
         unsigned char header_version;               // offset 6: typically 1
166
   unsigned char header_version;               // offset 6: typically 1
157
         unsigned char os_abi;                       // offset 7: 0 = SysV, 1 = HP/UX, 2 = NetBSD, 3 = Linux, 4 = GNU/Hurd, 6 = Solaris, 7 = AIX, 8 = IRIX, 9 = FreeBSD, 10 = Tru64, 11 = Novell, 12 = OpenBSD, 13 = OpenVMS, 14 = NonStop kernel, 15 = AROS, 16 = FenixOS, 17 = Nuxi CloudABI, 18 = OpenVOS
167
   unsigned char os_abi;                       // offset 7: 0 = SysV, 1 = HP/UX, 2 = NetBSD, 3 = Linux, 4 = GNU/Hurd, 6 = Solaris, 7 = AIX, 8 = IRIX, 9 = FreeBSD, 10 = Tru64, 11 = Novell, 12 = OpenBSD, 13 = OpenVMS, 14 = NonStop kernel, 15 = AROS, 16 = FenixOS, 17 = Nuxi CloudABI, 18 = OpenVOS
158
         unsigned char spare[8];                     // offset 8: zeroes
168
   unsigned char spare[8];                     // offset 8: zeroes
159
         unsigned __int16 type;                        // offset 16: 1 = relocatable, 2 = executable, 3 = shared, 4 = core dump
169
   unsigned __int16 type;                        // offset 16: 1 = relocatable, 2 = executable, 3 = shared, 4 = core dump
160
         unsigned __int16 instruction_set;             // offset 18: 2 = Sparc, 3 = i386, 8 = MIPS, 20 = PowerPC, 40 = ARM, 42 = SuperH, 50 = IA-64, 62 = x86_64, 183 = AArch64, 243 = RISC-V
170
   unsigned __int16 instruction_set;             // offset 18: 2 = Sparc, 3 = i386, 8 = MIPS, 20 = PowerPC, 40 = ARM, 42 = SuperH, 50 = IA-64, 62 = x86_64, 183 = AArch64, 243 = RISC-V
161
         unsigned __int32 elf_version;                 // offset 20: typically 1
171
   unsigned __int32 elf_version;                 // offset 20: typically 1
162
         unsigned __int64 entrypoint_offset;           // offset 24: program entry offset
172
   unsigned __int64 entrypoint_offset;           // offset 24: program entry offset
163
         unsigned __int64 program_header_table_offset; // offset 32: offset to program header table
173
   unsigned __int64 program_header_table_offset; // offset 32: offset to program header table
164
         unsigned __int64 section_header_table_offset; // offset 40: offset to section header table
174
   unsigned __int64 section_header_table_offset; // offset 40: offset to section header table
165
         unsigned __int32 flags;                       // offset 48: flags (architecture-dependent, none for x86)
175
   unsigned __int32 flags;                       // offset 48: flags (architecture-dependent, none for x86)
166
         unsigned __int16 header_size;                 // offset 52: size of ELF header, 52 for 32-bit ELF and 64 for 64-bit ELF
176
   unsigned __int16 header_size;                 // offset 52: size of ELF header, 52 for 32-bit ELF and 64 for 64-bit ELF
167
         unsigned __int16 program_header_item_size;    // offset 54: size of an entry in the program header table
177
   unsigned __int16 program_header_item_size;    // offset 54: size of an entry in the program header table
168
         unsigned __int16 program_header_table_len;    // offset 56: number of entries in the program header table
178
   unsigned __int16 program_header_table_len;    // offset 56: number of entries in the program header table
169
         unsigned __int16 section_header_item_size;    // offset 58: size of an entry in the section header table
179
   unsigned __int16 section_header_item_size;    // offset 58: size of an entry in the section header table
170
         unsigned __int16 section_header_table_len;    // offset 60: number of entries in the section header table
180
   unsigned __int16 section_header_table_len;    // offset 60: number of entries in the section header table
171
         unsigned __int16 section_header_names_idx;    // offset 62: index of the entry in the section header table that contains the section names
181
   unsigned __int16 section_header_names_idx;    // offset 62: index of the entry in the section header table that contains the section names
172
} elf64_header_t;
182
} elf64_header_t;
173
 
183
 
174
 
184
 
175
// Executable and Linkable Format program header structure type definition
185
// Executable and Linkable Format program header structure type definition
176
typedef struct elf32_program_header_s
186
typedef struct elf32_program_header_s
177
{
187
{
178
         unsigned __int32 segment_type;   // offset 0: type of segment (0: unused table entry, 1: loadable, 2: dynamic linking information, 3: interpreter information, 4: auxiliary information, 5: reserved, 6: this very segment, 7: TLS template)
188
   unsigned __int32 segment_type;   // offset 0: type of segment (0: unused table entry, 1: loadable, 2: dynamic linking information, 3: interpreter information, 4: auxiliary information, 5: reserved, 6: this very segment, 7: TLS template)
179
         unsigned __int32 file_offset;    // offset 4: file offset of this segment
189
   unsigned __int32 file_offset;    // offset 4: file offset of this segment
180
         unsigned __int32 virtual_addr;   // offset 8: virtual address where this segment should be mapped in memory
190
   unsigned __int32 virtual_addr;   // offset 8: virtual address where this segment should be mapped in memory
181
         unsigned __int32 physical_addr;  // offset 12: on systems where this is relevant, PHYSICAL address where this segment should be mapped in memory
191
   unsigned __int32 physical_addr;  // offset 12: on systems where this is relevant, PHYSICAL address where this segment should be mapped in memory
182
         unsigned __int32 size_in_file;   // offset 16: size of this segment in the ELF file (may be zero)
192
   unsigned __int32 size_in_file;   // offset 16: size of this segment in the ELF file (may be zero)
183
         unsigned __int32 size_in_memory; // offset 20: size of this segment in memory (may be zero)
193
   unsigned __int32 size_in_memory; // offset 20: size of this segment in memory (may be zero)
184
         unsigned __int32 segment_flags;  // offset 24: bitmap of segment flags (1: executable, 2: writable, 4: readable)
194
   unsigned __int32 segment_flags;  // offset 24: bitmap of segment flags (1: executable, 2: writable, 4: readable)
185
         unsigned __int32 alignment;      // offset 28: memory alignment (0 or 1 mean non alignment, else must be a power of 2 where virtual_addr == file_offset % alignment)
195
   unsigned __int32 alignment;      // offset 28: memory alignment (0 or 1 mean non alignment, else must be a power of 2 where virtual_addr == file_offset % alignment)
186
      } elf32_program_header_t;
196
} elf32_program_header_t;
187
typedef struct elf64_program_header_s
197
typedef struct elf64_program_header_s
188
{
198
{
189
         unsigned __int32 segment_type;   // offset 0: type of segment (0: unused table entry, 1: loadable, 2: dynamic linking information, 3: interpreter information, 4: auxiliary information, 5: reserved, 6: this very segment, 7: TLS template)
199
   unsigned __int32 segment_type;   // offset 0: type of segment (0: unused table entry, 1: loadable, 2: dynamic linking information, 3: interpreter information, 4: auxiliary information, 5: reserved, 6: this very segment, 7: TLS template)
190
         unsigned __int32 segment_flags;  // offset 4: bitmap of segment flags (1: executable, 2: writable, 4: readable)
200
   unsigned __int32 segment_flags;  // offset 4: bitmap of segment flags (1: executable, 2: writable, 4: readable)
191
         unsigned __int64 file_offset;    // offset 8: file offset of this segment
201
   unsigned __int64 file_offset;    // offset 8: file offset of this segment
192
         unsigned __int64 virtual_addr;   // offset 16: virtual address where this segment should be mapped in memory
202
   unsigned __int64 virtual_addr;   // offset 16: virtual address where this segment should be mapped in memory
193
         unsigned __int64 physical_addr;  // offset 24: on systems where this is relevant, PHYSICAL address where this segment should be mapped in memory
203
   unsigned __int64 physical_addr;  // offset 24: on systems where this is relevant, PHYSICAL address where this segment should be mapped in memory
194
         unsigned __int64 size_in_file;   // offset 32: size of this segment in the ELF file (may be zero)
204
   unsigned __int64 size_in_file;   // offset 32: size of this segment in the ELF file (may be zero)
195
         unsigned __int64 size_in_memory; // offset 40: size of this segment in memory (may be zero)
205
   unsigned __int64 size_in_memory; // offset 40: size of this segment in memory (may be zero)
196
         unsigned __int64 alignment;      // offset 48: memory alignment (0 or 1 mean non alignment, else must be a power of 2 where virtual_addr == file_offset % alignment)
206
   unsigned __int64 alignment;      // offset 48: memory alignment (0 or 1 mean non alignment, else must be a power of 2 where virtual_addr == file_offset % alignment)
197
      } elf64_program_header_t;
207
} elf64_program_header_t;
198
 
208
 
199
 
209
 
200
// Executable and Linkable Format section header structure type definition
210
// Executable and Linkable Format section header structure type definition
201
typedef struct elf32_section_header_s
211
typedef struct elf32_section_header_s
202
{
212
{
203
         unsigned __int32 name_offset;  // offset 0: offset in the string table of the name of this section
213
   unsigned __int32 name_offset;  // offset 0: offset in the string table of the name of this section
204
         unsigned __int32 type;         // offset 4:
214
   unsigned __int32 type;         // offset 4:
205
         unsigned __int32 flags;        // offset 8:
215
   unsigned __int32 flags;        // offset 8:
206
         unsigned __int32 virtual_addr; // offset 12: address in virtual memory where this section may be loaded
216
   unsigned __int32 virtual_addr; // offset 12: address in virtual memory where this section may be loaded
207
         unsigned __int32 file_offset;  // offset 16: offset of this section in the ELF file
217
   unsigned __int32 file_offset;  // offset 16: offset of this section in the ELF file
208
         unsigned __int32 size;         // offset 20: size of this section
218
   unsigned __int32 size;         // offset 20: size of this section
209
         unsigned __int32 linked_index; // offset 24: optional section index of an associated section
219
   unsigned __int32 linked_index; // offset 24: optional section index of an associated section
210
         unsigned __int32 info;         // offset 28: optional extra information
220
   unsigned __int32 info;         // offset 28: optional extra information
211
         unsigned __int32 alignment;    // offset 32: required memory alignment (must be a power of 2)
221
   unsigned __int32 alignment;    // offset 32: required memory alignment (must be a power of 2)
212
         unsigned __int32 entry_size;   // offset 36: for table-like sections, size of an element in the table
222
   unsigned __int32 entry_size;   // offset 36: for table-like sections, size of an element in the table
213
      } elf32_section_header_t;
223
} elf32_section_header_t;
214
typedef struct elf64_section_header_s
224
typedef struct elf64_section_header_s
215
      {
225
{
216
         unsigned __int32 name_offset;  // offset 0: offset in the string table of the name of this section
226
   unsigned __int32 name_offset;  // offset 0: offset in the string table of the name of this section
217
         unsigned __int32 type;         // offset 4:
227
   unsigned __int32 type;         // offset 4:
218
         unsigned __int64 flags;        // offset 8:
228
   unsigned __int64 flags;        // offset 8:
219
         unsigned __int64 virtual_addr; // offset 16: address in virtual memory where this section may be loaded
229
   unsigned __int64 virtual_addr; // offset 16: address in virtual memory where this section may be loaded
220
         unsigned __int64 file_offset;  // offset 24: offset of this section in the ELF file
230
   unsigned __int64 file_offset;  // offset 24: offset of this section in the ELF file
221
         unsigned __int64 size;         // offset 32: size of this section
231
   unsigned __int64 size;         // offset 32: size of this section
222
         unsigned __int32 linked_index; // offset 40: optional section index of an associated section
232
   unsigned __int32 linked_index; // offset 40: optional section index of an associated section
223
         unsigned __int32 info;         // offset 44: optional extra information
233
   unsigned __int32 info;         // offset 44: optional extra information
224
         unsigned __int64 alignment;    // offset 48: required memory alignment (must be a power of 2)
234
   unsigned __int64 alignment;    // offset 48: required memory alignment (must be a power of 2)
225
         unsigned __int64 entry_size;   // offset 56: for table-like sections, size of an element in the table
235
   unsigned __int64 entry_size;   // offset 56: for table-like sections, size of an element in the table
226
      } elf64_section_header_t;
236
} elf64_section_header_t;
227
 
237
 
228
 
238
 
229
// Executable and Linkable Format dynamic section entry structure type definition
239
// Executable and Linkable Format dynamic section entry structure type definition
230
typedef struct elf32_dynamic_section_entry_s
240
typedef struct elf32_dynamic_section_entry_s
231
{
241
{
232
         __int32 tag; // dynamic entry type (one of ELF_DT_xxx #defines)
242
   __int32 tag; // dynamic entry type (one of ELF_DT_xxx #defines)
233
         unsigned __int32 integer_or_pointer; // value as integer
243
   unsigned __int32 integer_or_pointer; // value as integer
234
      } elf32_dynamic_section_entry_t;
244
} elf32_dynamic_section_entry_t;
235
typedef struct elf32_dynamic_section_entry_s
245
typedef struct elf64_dynamic_section_entry_s
236
{
246
{
237
         __int64 tag; // dynamic entry type (one of ELF_DT_xxx #defines)
247
   __int64 tag; // dynamic entry type (one of ELF_DT_xxx #defines)
238
         unsigned __int64 integer_or_pointer; // value as intege
248
   unsigned __int64 integer_or_pointer; // value as intege
239
      } elf64_dynamic_section_entry_t;
249
} elf64_dynamic_section_entry_t;