root / Whitix / branches / network / include / elf.h

Revision 7, 2.7 kB (checked in by root, 10 months ago)

Rework build system, fix linker code.

Line 
1/*  This file is part of Whitix.
2 *
3 *  Whitix is free software; you can redistribute it and/or modify
4 *  it under the terms of the GNU General Public License as published by
5 *  the Free Software Foundation; either version 2 of the License, or
6 *  (at your option) any later version.
7 *
8 *  Whitix is distributed in the hope that it will be useful,
9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 *  GNU General Public License for more details.
12 *
13 *  You should have received a copy of the GNU General Public License
14 *  along with Whitix; if not, write to the Free Software
15 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16 *
17 */
18
19#ifndef ELF_H
20#define ELF_H
21
22#include <typedefs.h>
23
24#define PUSH_AUX_ENT(stackP,id,value) \
25        do { \
26        STACK_PUSH((stackP),(value)); \
27        STACK_PUSH((stackP),(id)); \
28        }while(0)
29
30#define AT_NULL         0
31#define AT_IGNORE       1
32#define AT_EXECFD       2
33#define AT_PHDR         3
34#define AT_PHENT        4
35#define AT_PHNUM        5
36#define AT_PAGESZ       6
37#define AT_BASE         7
38#define AT_FLAGS        8
39#define AT_ENTRY        9
40#define AT_NOTELF       10
41#define AT_UID          11
42#define AT_EUID         12
43#define AT_GID          13
44#define AT_EGID         14
45
46#define ELF_HEAD_CHECK(header) ((header)->elfMagic[0] == 0x7F && (header)->elfMagic[1] == 'E' && (header)->elfMagic[2] == 'L' \
47                && (header)->elfMagic[3] == 'F')
48
49/* ELF file types */
50#define ELF_EXEC 2
51#define ELF_DYN 3
52
53/* ELF segment types */
54#define ELF_TYPE_LOAD   1
55#define ELF_TYPE_DYN    2
56#define ELF_TYPE_INTERP 3
57
58/* ELF permissions */
59#define ELF_PERMS_RW    2
60
61/* ElfCheckHeader - sanity checks the ELF header */
62#define ElfCheckHeader(header,type) \
63        (!ELF_HEAD_CHECK(header) || !((header)->fileType & (type)) || header->phEntrySize != sizeof(struct ElfSegmentHeader))
64
65struct ElfHeader
66{
67        char elfMagic[4];
68        BYTE bitness,endian,elfVer,reserved;
69        DWORD reserved2[2];
70        WORD fileType,machine;
71        DWORD elfVer2;
72        DWORD entryPoint;
73        DWORD phOffset;
74        DWORD shOffset;
75        DWORD flags;
76        WORD thisSize,phEntrySize;
77        WORD phEntries,shEntrySize;
78        WORD shEntries,strTabSectionIndex;
79}PACKED;
80
81struct ElfSegmentHeader
82{
83        DWORD type;
84        DWORD fileOffset;
85        DWORD virtualAddr;
86        DWORD physAddr;
87        DWORD fileSize;
88        DWORD memSize;
89        DWORD segFlags;
90        DWORD segAlign;
91}PACKED;
92
93struct ElfSectionHeader
94{
95        DWORD shName;
96        DWORD shType;
97        DWORD shFlags;
98        DWORD shAddr;
99        DWORD shOffset;
100        DWORD shSize;
101        DWORD shLink;
102        DWORD shInfo;
103        DWORD shAddrAlign;
104        DWORD shEntSize;
105}PACKED;
106
107struct ElfSymbol
108{
109        DWORD symName;
110        DWORD symValue;
111        DWORD symSize;
112        BYTE symInfo;
113        BYTE symOther;
114        WORD symIndex;
115}PACKED;
116
117#endif
Note: See TracBrowser for help on using the browser.