FreeNOS
ELF.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIBEXEC_ELF_H
19 #define __LIBEXEC_ELF_H
20 
21 #include <Types.h>
22 #include <Factory.h>
23 #include "ExecutableFormat.h"
24 #include "ELFHeader.h"
25 
37 class ELF : public ExecutableFormat
38 {
39  public:
40 
47  ELF(const u8 *image, const Size size);
48 
52  virtual ~ELF();
53 
65  virtual Result regions(Region *regions, Size *count) const;
66 
74  virtual Result entry(Address *entry) const;
75 
85  static Result detect(const u8 *image, const Size size, ExecutableFormat **fmt);
86 };
87 
93 #endif /* __LIBEXEC_ELF_H */
ELF::detect
static Result detect(const u8 *image, const Size size, ExecutableFormat **fmt)
Read ELF header from memory.
Definition: ELF.cpp:30
ExecutableFormat.h
ELF::~ELF
virtual ~ELF()
Class destructor.
Definition: ELF.cpp:26
Types.h
ExecutableFormat::Region
Memory region.
Definition: ExecutableFormat.h:55
ELF::entry
virtual Result entry(Address *entry) const
Lookup the program entry point.
Definition: ELF.cpp:87
Address
unsigned long Address
A memory address.
Definition: Types.h:131
ELFHeader.h
ExecutableFormat::Result
Result
Result code.
Definition: ExecutableFormat.h:68
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
u8
unsigned char u8
Unsigned 8-bit number.
Definition: Types.h:59
ELF::regions
virtual Result regions(Region *regions, Size *count) const
Reads out segments from the ELF program table.
Definition: ELF.cpp:52
ELF
Executable and Linkable Format (ELF).
Definition: ELF.h:37
ELF::ELF
ELF(const u8 *image, const Size size)
Class constructor.
Definition: ELF.cpp:21
Factory.h
ExecutableFormat
Abstraction class of various executable formats.
Definition: ExecutableFormat.h:48