VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/ldrELF32.h@ 32197

最後變更 在這個檔案從32197是 32197,由 vboxsync 提交於 15 年 前

Runtime: Our own ldrELF32,64.h headers. Renamed ldrElf.h->ldrELF.h.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 5.7 KB
 
1/* $Id: ldrELF32.h 32197 2010-09-02 13:22:21Z vboxsync $ */
2/** @file
3 * IPRT - ELF 32-bit header.
4 */
5
6/*
7 * Copyright (C) 2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___internal_ldrELF32_h
19#define ___internal_ldrELF32_h
20
21#include <iprt/assert.h>
22
23#include "ldrELFCommon.h"
24
25/*
26 * ELF 32 standard types.
27 */
28typedef uint32_t Elf32_Addr;
29typedef uint16_t Elf32_Half;
30typedef uint32_t Elf32_Off;
31typedef int32_t Elf32_Sword;
32typedef uint32_t Elf32_Word;
33
34/*
35 * Ensure type size correctness in accordance to .
36 * Portable Format Specification (for ELF), Version 1.1, fig 1-2. .
37 */
38AssertCompileSize(Elf32_Addr, 4);
39AssertCompileSize(Elf32_Half, 2);
40AssertCompileSize(Elf32_Off, 4);
41AssertCompileSize(Elf32_Sword, 4);
42AssertCompileSize(Elf32_Word, 4);
43
44/*
45 * ELF 32 non-standard types for convenience.
46 */
47typedef Elf32_Word Elf32_Size;
48typedef Elf32_Word Elf32_Hashelt;
49
50/*
51 * ELF header.
52 */
53typedef struct
54{
55 unsigned char e_ident[16]; /* ELF identification. */
56 Elf32_Half e_type; /* Object file type. */
57 Elf32_Half e_machine; /* Machine type. */
58 Elf32_Word e_version; /* Object file version. */
59 Elf32_Addr e_entry; /* Entry point address. */
60 Elf32_Off e_phoff; /* Program header offset. */
61 Elf32_Off e_shoff; /* Section header offset. */
62 Elf32_Word e_flags; /* Processor-specific flags. */
63 Elf32_Half e_ehsize; /* ELF header size. */
64 Elf32_Half e_phentsize; /* Size of program header entries. */
65 Elf32_Half e_phnum; /* Number of program headers. */
66 Elf32_Half e_shentsize; /* Size of section header entries. */
67 Elf32_Half e_shnum; /* Number of section headers. */
68 Elf32_Half e_shstrndx; /* Section name string table index. */
69} Elf32_Ehdr;
70
71/*
72 * Section header.
73 */
74typedef struct
75{
76 Elf32_Word sh_name; /* Section name. */
77 Elf32_Word sh_type; /* Section type. */
78 Elf32_Word sh_flags; /* Section attributes. */
79 Elf32_Addr sh_addr; /* Virtual address in memory. */
80 Elf32_Off sh_offset; /* Offset in file. */
81 Elf32_Word sh_size; /* Size of section. */
82 Elf32_Word sh_link; /* Link to other section. */
83 Elf32_Word sh_info; /* Miscellaneous information. */
84 Elf32_Word sh_addralign; /* Address alignment boundary. */
85 Elf32_Word sh_entsize; /* Size of entries, if section has table. */
86} Elf32_Shdr;
87
88
89/*
90 * Program header.
91 */
92typedef struct
93{
94 Elf32_Word p_type; /* Type of segment. */
95 Elf32_Off p_offset; /* Offset in file. */
96 Elf32_Addr p_vaddr; /* Virtual address in memory. */
97 Elf32_Addr p_paddr; /* Physical address (reserved). */
98 Elf32_Word p_filesz; /* Size of segment in file. */
99 Elf32_Word p_memsz; /* Size of segment in memory. */
100 Elf32_Word p_flags; /* Segment attributes. */
101 Elf32_Word p_align; /* Alignment of segment. */
102} Elf32_Phdr;
103
104
105/*
106 * Note header.
107 */
108typedef struct
109{
110 Elf32_Word n_namesz; /* Length of note's name. */
111 Elf32_Word n_descsz; /* Length of note's description. */
112 Elf32_Word n_type; /* Type of note. */
113} Elf32_Nhdr;
114
115
116/*
117 * Symbol table entry.
118 */
119typedef struct
120{
121 Elf32_Word st_name; /* Symbol name. */
122 Elf32_Addr st_value; /* Symbol value. */
123 Elf32_Word st_size; /* Size associated with symbol. */
124 unsigned char st_info; /* Type and binding attributes. */
125 unsigned char st_other; /* Reserved. */
126 Elf32_Half st_shndx; /* Section header table index. */
127} Elf32_Sym;
128
129
130/*
131 * Relocations.
132 */
133typedef struct
134{
135 Elf32_Addr r_offset; /* Location to be relocated. */
136 Elf32_Word r_info; /* Symbol index and type of relocation. */
137} Elf32_Rel;
138
139typedef struct
140{
141 Elf32_Addr r_offset; /* Location to be relocated. */
142 Elf32_Word r_info; /* Symbol index and type of relocation. */
143 Elf32_Sword r_addend; /* Constant part of expression. */
144} Elf32_Rela;
145
146/*
147 * Dynamic section entry.
148 * ".dynamic" section contains an array of this.
149 */
150typedef struct
151{
152 Elf32_Sword d_tag; /* Type of entry. */
153 union
154 {
155 Elf32_Word d_val; /* Integer value. */
156 Elf32_Addr d_ptr; /* Virtual address value. */
157 } d_un;
158} Elf32_Dyn;
159
160/*
161 * Helper macros.
162 */
163/** The symbol's type. */
164#define ELF32_ST_TYPE(info) ((info) & 0xF)
165/** The symbol's binding. */
166#define ELF32_ST_BIND(info) ((info) >> 4)
167/** Make st_info. given binding and type. */
168#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
169
170/** Relocation type. */
171#define ELF32_R_TYPE(info) ((unsigned char)(info))
172/** Relocation symbol index. */
173#define ELF32_R_SYM(info) ((info) >> 8)
174/** Make r_info given the symbol index and type. */
175#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))
176
177
178#endif /* ___internal_ldrELF32_h */
179
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette