This module provides functions to handle program headers. In ELF, the programs headers provide a way to build quickly the memory image of a program. Although there is different types of programs headers, the main type is PT_LOAD that provides information to load code or data from the ELF file to the memory. There is several other types for dynamic linking, compiler notes and so on.
The program headers may be handled using the gel_prog_t pointers and information may be obtained into a gel_prog_info_t structure. A simple way to get a program header is the use of index with the function gel_getprogbyidx().
The PT_NOTE program header may be scanned using the functions: gel_note_init(), gel_note_next(), gel_note_destroy(), gel_note_name(), gel_note_type(), gel_note_size() and gel_note_desc().
◆ gel_note_desc
| #define gel_note_desc |
( |
|
c | ) |
((c)->desc) |
Get a cursor on the description of the note.
- Parameters
-
- Returns
- Cursor on the description of the note.
◆ gel_note_name
| #define gel_note_name |
( |
|
c | ) |
((c)->name) |
Get the name of the current note.
- Parameters
-
- Returns
- Name of the note.
◆ gel_note_size
| #define gel_note_size |
( |
|
c | ) |
((c)->desc.size) |
Get the size of the description part of the note.
- Parameters
-
| c | Cursor on the current note. |
◆ gel_note_type
| #define gel_note_type |
( |
|
c | ) |
((c)->type) |
Get the type of the current note.
- Parameters
-
- Returns
- Type of the note.
◆ PF_MASKOS
| #define PF_MASKOS 0x0ff00000 |
Program header flag: OS-specific mask.
◆ PF_MASKPROC
| #define PF_MASKPROC 0xf0000000 |
Program header flag: processor specific mask.
◆ PF_R
Program header flag: segment readable.
◆ PF_W
Program header flag: segment writable.
◆ PF_X
Program header flag: segment executable.
◆ PT_DYNAMIC
Program header type: information for dynamic linking.
◆ PT_HIPROC
| #define PT_HIPROC 0x7fffffff |
Program header type: hig index for processor specific program header.
◆ PT_INTERP
Program header type: information about the program interpreter.
◆ PT_LOAD
Program header type: loadable segment.
◆ PT_LOPROC
| #define PT_LOPROC 0x70000000 |
Program header type: low index for processor specific program header.
◆ PT_NOTE
Program header type: generic note.
◆ PT_NULL
Program header type: null.
◆ PT_PHDR
Program header type: position in memory of the program header table.
◆ PT_SHLIB
Program header type: shared library information.
◆ gel_note_t
Cursor for the content of PT_NOTE program header.
◆ gel_prog_t
Handle for a program header. The program headers may obtained by calling the function gel_getprogbyidx().
◆ gel_getprogbyidx()
Get a program header handler from its index. The allocated is automatically managed by the file handler and does not any to be fried by the caller.
- Parameters
-
| e | File descriptor. |
| idx | Index of the required program header. |
- Returns
- Program header handle or null if there is an error.
◆ gel_note_destroy()
Free a note cursor.
- Parameters
-
◆ gel_note_init()
Initialize a note cursor.
- Parameters
-
| phdr | Program header to use. |
| curs | Used cursor. |
- Returns
- 0 for success, -1 else.
◆ gel_note_next()
Get the next note.
- Parameters
-
- Returns
- 0 for success. -1 if en is reahced ((gel_errno == 0) or if there is an error (gel_errno != 0).
◆ gel_prog2cursor()
Create a cursor on the buffer represented by a program header (loading the program header if needed).
- Parameters
-
| p | Program header. |
| c | Cursor instance. |
- Returns
- Error code (0 for success, -1 for failure).
◆ gel_prog_infos()
Get public information for the program header handle. Notice that the got information will become inconsistant as soon as the program header is destroyed.
- Parameters
-
| e | Program header handle. |
| pi | Structure receiving information. |
- Returns
- 0 for success, -1 for error.
- Deprecated:
- Public information are now straight-forward reachable from the handle.
◆ gel_prog_load()
Load the rough content of a loadable segment at the given address or, if null, to a memory allocated by GEL.
- Parameters
-
| p | Program header handle to load. |
| addr | Address to load to or null for automatic allocation. |
- Returns
- 0 for success, -1 for error.