VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/ldrELF64.h@ 32219

Last change on this file since 32219 was 32197, checked in by vboxsync, 14 years ago

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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1/* $Id: ldrELF64.h 32197 2010-09-02 13:22:21Z vboxsync $ */
2/** @file
3 * IPRT - ELF 64-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.virtualbox.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_ldrELF64_h
19#define ___internal_ldrELF64_h
20
21#include <iprt/assert.h> /* Added by Ramshankar */
22
23#include "ldrELFCommon.h"
24
25/*
26 * ELF 64 standard types.
27 */
28typedef uint64_t Elf64_Addr;
29typedef uint64_t Elf64_Off;
30typedef uint16_t Elf64_Half;
31typedef uint32_t Elf64_Word;
32typedef int32_t Elf64_Sword;
33typedef uint64_t Elf64_Xword;
34typedef int64_t Elf64_Sxword;
35
36/*
37 * Ensure type size correctness in accordance to ELF-64 Object File Format, Version 1.5 Draft 2, p2.
38 */
39AssertCompileSize(Elf64_Addr, 8);
40AssertCompileSize(Elf64_Off, 8);
41AssertCompileSize(Elf64_Half, 2);
42AssertCompileSize(Elf64_Word, 4);
43AssertCompileSize(Elf64_Sword, 4);
44AssertCompileSize(Elf64_Xword, 8);
45AssertCompileSize(Elf64_Sxword, 8);
46
47/*
48 * ELF 64 non-standard types for convenience.
49 */
50typedef Elf64_Xword Elf64_Size;
51typedef Elf64_Word Elf64_Hashelt;
52
53/*
54 * ELF Header.
55 */
56typedef struct
57{
58 unsigned char e_ident[16]; /* ELF identification. */
59 Elf64_Half e_type; /* Object file type. */
60 Elf64_Half e_machine; /* Machine type. */
61 Elf64_Word e_version; /* Object file version. */
62 Elf64_Addr e_entry; /* Entry point address. */
63 Elf64_Off e_phoff; /* Program header offset. */
64 Elf64_Off e_shoff; /* Section header offset. */
65 Elf64_Word e_flags; /* Processor-specific flags. */
66 Elf64_Half e_ehsize; /* ELF header size. */
67 Elf64_Half e_phentsize; /* Size of program header entry. */
68 Elf64_Half e_phnum; /* Number of program header entries. */
69 Elf64_Half e_shentsize; /* Size of section header entry. */
70 Elf64_Half e_shnum; /* Number of section header entries. */
71 Elf64_Half e_shstrndx; /* Section name string table index. */
72} Elf64_Ehdr;
73
74/*
75 * Section header.
76 */
77typedef struct
78{
79 Elf64_Word sh_name; /* Section name. */
80 Elf64_Word sh_type; /* Section type. */
81 Elf64_Xword sh_flags; /* Section attributes. */
82 Elf64_Addr sh_addr; /* Virtual address in memory. */
83 Elf64_Off sh_offset; /* Offset in file. */
84 Elf64_Xword sh_size; /* Size of section. */
85 Elf64_Word sh_link; /* Link to other section. */
86 Elf64_Word sh_info; /* Miscellaneous information. */
87 Elf64_Xword sh_addralign; /* Address alignment boundary. */
88 Elf64_Xword sh_entsize; /* Size of entries, if section has table. */
89} Elf64_Shdr;
90
91/*
92 * Program header.
93 */
94typedef struct
95{
96 Elf64_Word p_type; /* Type of segment. */
97 Elf64_Word p_flags; /* Segment attributes. */
98 Elf64_Off p_offset; /* Offset in file. */
99 Elf64_Addr p_vaddr; /* Virtual address in memory. */
100 Elf64_Addr p_paddr; /* Physical address (reserved). */
101 Elf64_Xword p_filesz; /* Size of segment in file. */
102 Elf64_Xword p_memsz; /* Size of segment in memory. */
103 Elf64_Xword p_align; /* Alignment of segment. */
104} Elf64_Phdr;
105
106/*
107 * Note header.
108 */
109typedef struct
110{
111 Elf64_Word n_namesz; /* Length of note's name. */
112 Elf64_Word n_descsz; /* Length of note's description. */
113 Elf64_Word n_type; /* Type of note. */
114} Elf64_Nhdr;
115
116/*
117 * Symbol table entry.
118 */
119typedef struct
120{
121 Elf64_Word st_name; /* Symbol name. */
122 unsigned char st_info; /* Type and binding attributes. */
123 unsigned char st_other; /* Reserved. */
124 Elf64_Half st_shndx; /* Section header table index. */
125 Elf64_Addr st_value; /* Symbol value. */
126 Elf64_Xword st_size; /* Size associated with symbol. */
127} Elf64_Sym;
128
129/*
130 * Relocations.
131 */
132typedef struct
133{
134 Elf64_Addr r_offset; /* Location to be relocated. */
135 Elf64_Xword r_info; /* Symbol index and type of relocation. */
136} Elf64_Rel;
137
138typedef struct
139{
140 Elf64_Addr r_offset; /* Location to be relocated. */
141 Elf64_Xword r_info; /* Symbol index and type of relocation. */
142 Elf64_Sxword r_addend; /* Constant part of expression. */
143} Elf64_Rela;
144
145/*
146 * Dynamic section entry.
147 * ".dynamic" section contains an array of this.
148 */
149typedef struct
150{
151 Elf64_Sxword d_tag; /* Type of entry. */
152 union
153 {
154 Elf64_Xword d_val; /* Integer value. */
155 Elf64_Addr d_ptr; /* Virtual address value. */
156 } d_un;
157} Elf64_Dyn;
158
159/*
160 * Helper macros.
161 */
162/** The symbol's type. */
163#define ELF64_ST_TYPE(info) ((info) & 0xF)
164/** The symbol's binding. */
165#define ELF64_ST_BIND(info) ((info) >> 4)
166/** Make st_info. given binding and type. */
167#define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
168
169/** Relocation type. */
170#define ELF64_R_TYPE(info) ((unsigned char)(info))
171/** Relocation symbol index. */
172#define ELF64_R_SYM(info) ((info) >> 32)
173/** Make r_info given the symbol index and type. */
174#define ELF64_R_INFO(sym, type) (((sym) << 32) + (unsigned char)(type))
175
176
177#endif /* ___internal_ldrELF64_h */
178
Note: See TracBrowser for help on using the repository browser.

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