RTEMS 6.1-rc2
|
RTEMS Run-Time Linker Error. More...
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <rtems/libio_.h>
#include <rtems/rtl/rtl.h>
#include "rtl-chain-iterator.h"
#include <rtems/rtl/rtl-obj.h>
#include "rtl-error.h"
#include "rtl-find-file.h"
#include "rtl-string.h"
#include <rtems/rtl/rtl-trace.h>
#include "rtl-rap.h"
#include "rtl-elf.h"
Data Structures | |
struct | rtems_rtl_obj_unresolved_data |
struct | rtems_rtl_obj_sect_summer_data |
struct | rtems_rtl_obj_sect_aligner_data |
struct | rtems_rtl_obj_sect_finder |
struct | rtems_rtl_obj_sect_sync_ctx |
Macros | |
#define | RTEMS_RTL_ELF_LOADER 1 |
#define | RTEMS_RTL_RAP_LOADER 1 |
#define | RTEMS_RTL_RAP_LOADER_COUNT 1 |
#define | RTEMS_RTL_ELF_LOADER_COUNT 1 |
#define | RTEMS_RTL_LOADERS (RTEMS_RTL_ELF_LOADER_COUNT + RTEMS_RTL_RAP_LOADER_COUNT) |
Typedefs | |
typedef struct rtems_rtl_obj_unresolved_data | rtems_rtl_obj_unresolved_data |
RTEMS Run-Time Linker Error.
#define RTEMS_RTL_LOADERS (RTEMS_RTL_ELF_LOADER_COUNT + RTEMS_RTL_RAP_LOADER_COUNT) |
The table of supported loader formats.
bool rtems_rtl_obj_add_dependent | ( | rtems_rtl_obj * | obj, |
rtems_rtl_obj * | dependent | ||
) |
Add an object file to the dependents table.
obj | The object file's descriptor. |
dependent | The dependent object file to add. |
true | The dependent has been added to the table. |
false | There is no space in the table. |
bool rtems_rtl_obj_add_section | ( | rtems_rtl_obj * | obj, |
int | section, | ||
const char * | name, | ||
size_t | size, | ||
off_t | offset, | ||
uint32_t | alignment, | ||
int | link, | ||
int | info, | ||
uint32_t | flags | ||
) |
Add a section to the object descriptor.
obj | The object file's descriptor. |
section | The section's index number. |
name | The name of the section. |
size | The size of the section in memory. |
offset | The offset of the section in the object file. |
alignment | The alignment of the section in memory. |
link | The section's link field (from the ELF format). |
info | The section's info field (from the ELF format). |
flags | The section's flags. |
true | The section has been added. |
false | The section has not been added. See the RTL error. |
rtems_rtl_obj * rtems_rtl_obj_alloc | ( | void | ) |
Allocate an object structure on the heap.
NULL | No memory for the object. |
bool rtems_rtl_obj_alloc_dependents | ( | rtems_rtl_obj * | obj, |
size_t | dependents | ||
) |
Allocate a table for dependent objects.
obj | The object file's descriptor. |
dependents | The size of the table. |
true | The table was allocated. |
false | The alloction failed. |
bool rtems_rtl_obj_alloc_sections | ( | rtems_rtl_obj * | obj, |
int | fd, | ||
rtems_rtl_obj_sect_handler | handler, | ||
void * | data | ||
) |
Allocate the sections. If a handler is provided (not NULL) it is called for all section.
obj | The object file's descriptor. |
fd | The object file's file descriptor. |
handler | The object file's format specific allocation handler. |
data | User specific data handle. |
true | The object has been sucessfully loaded. |
false | The load failed. The RTL error has been set. |
uint32_t rtems_rtl_obj_bss_alignment | ( | const rtems_rtl_obj * | obj | ) |
The bss section alignment for the object file. Only use once all the sections has been added. The section alignment is the alignment of the first bss type section loaded the bss section.
You can assume the alignment is a positive integral power of 2 if not 0 or
obj | The object file's descriptor. |
size_t rtems_rtl_obj_bss_size | ( | const rtems_rtl_obj * | obj | ) |
The bss section size. Only use once all the sections has been added. It includes alignments between sections that are part of the object's bss area.
obj | The object file's descriptor. |
uint32_t rtems_rtl_obj_const_alignment | ( | const rtems_rtl_obj * | obj | ) |
The const section alignment for the object file. Only use once all the sections has been added. The section alignment is the alignment of the first const type section loaded the const section.
You can assume the alignment is a positive integral power of 2 if not 0 or
obj | The object file's descriptor. |
size_t rtems_rtl_obj_const_size | ( | const rtems_rtl_obj * | obj | ) |
The const section size. Only use once all the sections has been added. It includes alignments between sections that are part of the object's const area. The consts sections are included in this section.
obj | The object file's descriptor. |
bool rtems_rtl_obj_ctors_to_run | ( | rtems_rtl_obj * | obj | ) |
Does the object have constructors to run?
uint32_t rtems_rtl_obj_data_alignment | ( | const rtems_rtl_obj * | obj | ) |
The data section alignment for the object file. Only use once all the sections has been added. The section alignment is the alignment of the first data type section loaded the data section.
You can assume the alignment is a positive integral power of 2 if not 0 or
obj | The object file's descriptor. |
size_t rtems_rtl_obj_data_size | ( | const rtems_rtl_obj * | obj | ) |
The data section size. Only use once all the sections has been added. It includes alignments between sections that are part of the object's data area.
obj | The object file's descriptor. |
void rtems_rtl_obj_dec_reference | ( | rtems_rtl_obj * | obj | ) |
Decrement the object file reference count.
obj | The object file's descriptor. |
bool rtems_rtl_obj_dtors_to_run | ( | rtems_rtl_obj * | obj | ) |
Does the object have destructors to run?
uint32_t rtems_rtl_obj_eh_alignment | ( | const rtems_rtl_obj * | obj | ) |
The eh section alignment for the object file. Only use once all the sections has been added. The section alignment is the alignment of the first bss type section loaded the bss section.
You can assume the alignment is a positive integral power of 2 if not 0 or
obj | The object file's descriptor. |
size_t rtems_rtl_obj_eh_size | ( | const rtems_rtl_obj * | obj | ) |
The eh section size. Only use once all the sections has been added. It includes alignments between sections that are part of the object's bss area.
obj | The object file's descriptor. |
void rtems_rtl_obj_erase_dependents | ( | rtems_rtl_obj * | obj | ) |
Erase the object file descriptor's dependents.
obj | The object file's descriptor. |
void rtems_rtl_obj_erase_sections | ( | rtems_rtl_obj * | obj | ) |
Erase the object file descriptor's sections.
obj | The object file's descriptor. |
bool rtems_rtl_obj_find_file | ( | rtems_rtl_obj * | obj, |
const char * | name | ||
) |
Find an object file on disk that matches the name. The object descriptor is fill in with the various parts of a name. A name can have archive, object file and offset components. The search path in the RTL is searched.
obj | The object file's descriptor. |
name | The name to locate on disk. |
true | The file has been found. |
false | The file could not be located. The RTL error has been set. |
rtems_rtl_obj_sect * rtems_rtl_obj_find_section | ( | const rtems_rtl_obj * | obj, |
const char * | name | ||
) |
Find the section given a name.
obj | The object file's descriptor. |
name | The name of the section to find. |
NULL | The section was not found. |
rtems_rtl_obj_sect * rtems_rtl_obj_find_section_by_index | ( | const rtems_rtl_obj * | obj, |
int | index | ||
) |
Find a section given a section's index number.
obj | The object file's descriptor. |
index | The section's index to find. |
NULL | The section was not found. |
rtems_rtl_obj_sect * rtems_rtl_obj_find_section_by_mask | ( | const rtems_rtl_obj * | obj, |
int | index, | ||
uint32_t | mask | ||
) |
Find a section given a section's mask. The index is the section after which the mask is matched. An index of -1 starts the search from the beginning of the section list. You can find multiple matches for a mask by passing the index of the last section that matched the mask on a subsequent call.
obj | The object file's descriptor. |
index | The section's index to start searching from, -1 for the start. |
mask | The section's mask to match against the section's flags. |
NULL | The section was not found. |
bool rtems_rtl_obj_free | ( | rtems_rtl_obj * | obj | ) |
Free the object structure and related resources.
obj | The object file's descriptor to free. |
false | The object has dependences. |
true | The object has been freed. |
size_t rtems_rtl_obj_get_reference | ( | rtems_rtl_obj * | obj | ) |
Get the object file reference count.
int | The object file's reference count. |
void rtems_rtl_obj_inc_reference | ( | rtems_rtl_obj * | obj | ) |
Increment the object file reference count.
obj | The object file's descriptor. |
bool rtems_rtl_obj_iterate_dependents | ( | rtems_rtl_obj * | obj, |
rtems_rtl_obj_depends_iterator | iterator, | ||
void * | data | ||
) |
Iterate over the module dependenices.
obj | The object file's descriptor. |
handler | The iterator handler. Returns true to end. |
data | User data passed to the iterator. |
true | The iterator handler returned true. |
false | The iterator handler returned false. |
bool rtems_rtl_obj_load | ( | rtems_rtl_obj * | obj | ) |
Load the object file, reading all sections into memory, symbols and performing any relocation fixups.
obj | The object file's descriptor. |
true | The object file has been loaded. |
false | The load failed. The RTL error has been set. |
bool rtems_rtl_obj_load_sections | ( | rtems_rtl_obj * | obj, |
int | fd, | ||
rtems_rtl_obj_sect_handler | handler, | ||
void * | data | ||
) |
Load the sections that have been allocated memory in the target. The bss type section does not load any data, it is set to 0. The text and data sections read the detault data from the object file into the target memory.
obj | The object file's descriptor. |
fd | The object file's file descriptor. |
handler | The object file's format specific load handler. |
data | User specific data handle. |
true | The object has been sucessfully loaded. |
false | The load failed. The RTL error has been set. |
bool rtems_rtl_obj_load_symbols | ( | rtems_rtl_obj * | obj, |
int | fd, | ||
rtems_rtl_obj_sect_handler | handler, | ||
void * | data | ||
) |
Load the symbols from the object file. Only the exported or public symbols are read into memory and held in the global symbol table.
obj | The object file's descriptor. |
fd | The object file's file descriptor. |
handler | The object file's format specific symbol handler. |
data | User specific data handle. |
true | The object file's symbol where loaded. |
false | The symbol loading failed. The RTL error is set. |
bool rtems_rtl_obj_orphaned | ( | rtems_rtl_obj * | obj | ) |
Is the object file orphaned? An orphaned object file is not locked, has no users and it not being referenced.
obj | The object file's descriptor. |
bool rtems_rtl_obj_relocate | ( | rtems_rtl_obj * | obj, |
int | fd, | ||
rtems_rtl_obj_sect_handler | handler, | ||
void * | data | ||
) |
Relocate the object file. The object file's section are parsed for any relocation type sections.
obj | The object file's descriptor. |
fd | The object file's file descriptor. |
handler | The object file's format specific relocation handler. |
data | User specific data handle. |
true | The object file was relocated. |
false | The relocation failed. The RTL error is set. |
bool rtems_rtl_obj_remove_dependencies | ( | rtems_rtl_obj * | obj | ) |
Remove dependencies. This decrements the dependent object file references.
obj | The object file's descriptor. |
true | The dependencies have been removed. |
false | There is no space in the table. |
bool rtems_rtl_obj_resize_sections | ( | rtems_rtl_obj * | obj | ) |
Resize the sections.
obj | The object file's descriptor. |
true | The object has been sucessfully loaded. |
false | The load failed. The RTL error has been set. |
void rtems_rtl_obj_run_ctors | ( | rtems_rtl_obj * | obj | ) |
Invoke the constructors the object has. Constructors are a table of pointers to "void (*)(void);" where NULL pointers are skipped. The table's size is taken from the section's size. The objet ELF specific code is responisble for flagging which sections contain constructors.
obj | The object file's descriptor. |
void rtems_rtl_obj_run_dtors | ( | rtems_rtl_obj * | obj | ) |
Invoke the destructors the object has. Destructors are a table of pointers to "void (*)(void);" where NULL pointers are skipped. The table's size is taken from the section's size. The objet ELF specific code is responisble for flagging which sections contain destructors.
obj | The object file's descriptor. |
void rtems_rtl_obj_synchronize_cache | ( | rtems_rtl_obj * | obj | ) |
Synchronize caches to make code visible to CPU(s)
obj | The object file's descriptor. |
uint32_t rtems_rtl_obj_text_alignment | ( | const rtems_rtl_obj * | obj | ) |
The text section alignment for the object file. Only use once all the sections has been added. The section alignment is the alignment of the first text type section loaded the text section.
You can assume the alignment is a positive integral power of 2 if not 0 or
obj | The object file's descriptor. |
size_t rtems_rtl_obj_text_size | ( | const rtems_rtl_obj * | obj | ) |
The text section size. Only use once all the sections has been added. It includes alignments between sections that are part of the object's text area. The consts sections are included in this section.
obj | The object file's descriptor. |
size_t rtems_rtl_obj_tramp_size | ( | const rtems_rtl_obj * | obj | ) |
The trampoline size.
obj | The object file's descriptor. |
bool rtems_rtl_obj_unload | ( | rtems_rtl_obj * | obj | ) |
Unload the object file, erasing all symbols and releasing all memory.
obj | The object file's descriptor. |
true | The object file has been unloaded. |
false | The unload failed. The RTL error has been set. |
bool rtems_rtl_obj_unresolved | ( | rtems_rtl_obj * | obj | ) |
Does the object file have unresolved external references ? If it does the results of executing code is unpredictable.
obj | The object file's descriptor. |
true | The object file has unresolved externals. |
false | The object file has all external references resolved. |
bool rtems_rtl_parse_name | ( | const char * | name, |
const char ** | aname, | ||
const char ** | oname, | ||
off_t * | ooffset | ||
) |
Parses a filename and returns newly allocated strings with the archive name, object name, and the object's offset
name | The filename of the object |
aname | Address of a string pointer that holds the archive name |
oname | Address of a string pointer that holds the object name |
ooffset | Address of an int that holds the object offset |
true | The parsing was successful |
false | The parsing was unsuccessful |