ELF Tutorial: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
mNo edit summary
Nuke useless and mostly unused section
Line 1: Line 1:
{{Rating|2}}{{File formats}}
{{Rating|2}}{{File formats}}
This tutorial describes the steps to loading ELF files targeting the i386 (32-bit architecture, little-endian byte order). All code in the tutorial is in the form of C compatible C++ and strives to teach by example, by using simplified (and sometimes naive), neat, and functional snippets of code. It may later be expanded to cover other types of ELF files, or formats targeting other architectures or machine types.
This tutorial describes the steps to loading ELF files targeting the i386 (32-bit architecture, little-endian byte order). All code in the tutorial is in the form of C compatible C++ and strives to teach by example, by using simplified (and sometimes naive), neat, and functional snippets of code. It may later be expanded to cover other types of ELF files, or formats targeting other architectures or machine types.

==Macro Definitions used in Examples==

The example code provided in this tutorial relies on a couple of preprocessor definitions, which can be found below. In addition, the code relies on a printf() function for printing debug information to the screen, malloc() for memory allocations, memset() for zeroing memory, and the stdint.h header for fixed width integer types.

<source lang="cpp">
# ifndef __cplusplus
# include <stdbool.h>
# define CLINK
# define CEXTERN extern
# else
# define CLINK extern "C"
# define CEXTERN extern "C"
# endif /* C++ */

# define WRITE(PRE, STR, ...) \
printf("[%s] %s() : ", (PRE), (__FUNCTION__)); \
printf(STR, __VA_ARGS__);

# define DEBUG(STR, ...) \
WRITE("INFO", STR, __VA_ARGS__);

# define WARN(STR, ...) \
WRITE("WARN", STR, __VA_ARGS__);
# define ERROR(STR, ...) \
WRITE("ERR!", STR, __VA_ARGS__);
</source>

Some additional macros will be defined along with their relevant examples or sections.


==ELF Data Types==
==ELF Data Types==