16 #if !defined (_RTEMS_RTL_OBJ_H_) 17 #define _RTEMS_RTL_OBJ_H_ 21 #include <rtems/rtl/rtl-sym.h> 22 #include <rtems/rtl/rtl-unresolved.h> 31 #define RTEMS_RTL_FMT_ELF (1 << 0) 32 #define RTEMS_RTL_FMT_COMP (1 << 1) 33 #define RTEMS_RTL_FMT_PRIVATE (1 << 16) 90 #define RTEMS_RTL_OBJ_SECT_TEXT (1 << 0) 91 #define RTEMS_RTL_OBJ_SECT_CONST (1 << 1) 92 #define RTEMS_RTL_OBJ_SECT_DATA (1 << 2) 93 #define RTEMS_RTL_OBJ_SECT_BSS (1 << 3) 94 #define RTEMS_RTL_OBJ_SECT_EH (1 << 4) 95 #define RTEMS_RTL_OBJ_SECT_REL (1 << 5) 96 #define RTEMS_RTL_OBJ_SECT_RELA (1 << 6) 98 #define RTEMS_RTL_OBJ_SECT_SYM (1 << 7) 99 #define RTEMS_RTL_OBJ_SECT_STR (1 << 8) 100 #define RTEMS_RTL_OBJ_SECT_ALLOC (1 << 9) 101 #define RTEMS_RTL_OBJ_SECT_LOAD (1 << 10) 102 #define RTEMS_RTL_OBJ_SECT_WRITE (1 << 11) 103 #define RTEMS_RTL_OBJ_SECT_EXEC (1 << 12) 104 #define RTEMS_RTL_OBJ_SECT_ZERO (1 << 13) 105 #define RTEMS_RTL_OBJ_SECT_LINK (1 << 14) 106 #define RTEMS_RTL_OBJ_SECT_CTOR (1 << 15) 107 #define RTEMS_RTL_OBJ_SECT_DTOR (1 << 16) 108 #define RTEMS_RTL_OBJ_SECT_LOCD (1 << 17) 113 #define RTEMS_RTL_OBJ_SECT_TYPES (RTEMS_RTL_OBJ_SECT_TEXT | \ 114 RTEMS_RTL_OBJ_SECT_CONST | \ 115 RTEMS_RTL_OBJ_SECT_DATA | \ 116 RTEMS_RTL_OBJ_SECT_BSS | \ 117 RTEMS_RTL_OBJ_SECT_EH) 144 #define RTEMS_RTL_OBJ_LOCKED (1 << 0) 146 #define RTEMS_RTL_OBJ_UNRESOLVED (1 << 1) 153 struct rtems_rtl_obj_s 222 static inline const char* rtems_rtl_obj_fname (
const rtems_rtl_obj_t* obj)
233 static inline bool rtems_rtl_obj_fname_valid (
const rtems_rtl_obj_t* obj)
244 static inline const char* rtems_rtl_obj_oname (
const rtems_rtl_obj_t* obj)
255 static inline bool rtems_rtl_obj_oname_valid (
const rtems_rtl_obj_t* obj)
266 static inline const char* rtems_rtl_obj_aname (
const rtems_rtl_obj_t* obj)
277 static inline bool rtems_rtl_obj_aname_valid (
const rtems_rtl_obj_t* obj)
288 static inline bool rtems_rtl_obj_text_inside (
const rtems_rtl_obj_t* obj,
size_t rtems_rtl_obj_text_size(const rtems_rtl_obj_t *obj)
The text section size.
Definition: rtl-obj.c:521
This is used to manage each element (node) which is placed on a chain.
Definition: chain.h:65
rtems_rtl_obj_t * rtems_rtl_obj_alloc(void)
Allocate an object structure on the heap.
Definition: rtl-obj.c:71
uint32_t rtems_rtl_obj_text_alignment(const rtems_rtl_obj_t *obj)
The text section alignment for the object file.
Definition: rtl-obj.c:527
Unresolved externals symbols require the relocation records to be held and references.
Definition: rtl-unresolved.h:94
Table for supported loadable formats.
Definition: rtl-obj.h:79
An object file is made up of sections and the can be more than one of a specific type of sections...
Definition: rtl-obj.h:125
bool rtems_rtl_obj_load_sections(rtems_rtl_obj_t *obj, int fd, rtems_rtl_obj_sect_handler_t handler, void *data)
Load the sections that have been allocated memory in the target.
Definition: rtl-obj.c:820
This is used to manage a chain.
Definition: chain.h:83
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...
Definition: rtl-obj.c:130
rtems_rtl_loader_load load
The loader.
Definition: rtl-obj.h:82
bool rtems_rtl_obj_relocate_unresolved(rtems_rtl_unresolv_reloc_t *reloc, rtems_rtl_obj_sym_t *sym)
Relocate an object file's unresolved reference.
Definition: rtl-elf.c:283
bool(* rtems_rtl_loader_load)(rtems_rtl_obj_t *obj, int fd)
The type of the format loader load handler.
Definition: rtl-obj.h:62
uint32_t rtems_rtl_obj_bss_alignment(const rtems_rtl_obj_t *obj)
The bss section alignment for the object file.
Definition: rtl-obj.c:575
bool rtems_rtl_obj_relocate(rtems_rtl_obj_t *obj, int fd, rtems_rtl_obj_sect_handler_t handler, void *data)
Relocate the object file.
Definition: rtl-obj.c:581
const char * oname
The object file name.
Definition: rtl-obj.h:163
rtems_rtl_obj_sect_t * rtems_rtl_obj_find_section_by_index(const rtems_rtl_obj_t *obj, int index)
Find a section given a section's index number.
Definition: rtl-obj.c:508
size_t text_size
The size of the text section.
Definition: rtl-obj.h:181
bool(* rtems_rtl_loader_unload)(rtems_rtl_obj_t *obj)
The type of the format loader unload handler.
Definition: rtl-obj.h:68
bool rtems_rtl_obj_add_section(rtems_rtl_obj_t *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.
Definition: rtl-obj.c:405
size_t rtems_rtl_obj_bss_size(const rtems_rtl_obj_t *obj)
The bss section size.
Definition: rtl-obj.c:569
An object file symbol.
Definition: rtl-sym.h:29
uint32_t rtems_rtl_obj_const_alignment(const rtems_rtl_obj_t *obj)
The const section alignment for the object file.
Definition: rtl-obj.c:551
bool rtems_rtl_obj_unresolved(rtems_rtl_obj_t *obj)
Does the object file have unresolved external references ? If it does the results of executing code i...
Definition: rtl-obj.c:124
rtems_rtl_obj_sect_t * rtems_rtl_obj_find_section(const rtems_rtl_obj_t *obj, const char *name)
Find the section given a name.
Definition: rtl-obj.c:482
uint32_t rtems_rtl_obj_eh_alignment(const rtems_rtl_obj_t *obj)
The eh section alignment for the object file.
Definition: rtl-obj.c:539
int link(const char *path1, const char *path2)
link() - POSIX 1003.1b - 5.3.4 - Create a new link
Definition: link.c:28
bool rtems_rtl_obj_free(rtems_rtl_obj_t *obj)
Free the object structure and related resources.
Definition: rtl-obj.c:102
void * text_base
The base address of the text section in memory.
Definition: rtl-obj.h:179
RTL Object.
Definition: rtl-obj.h:156
bool rtems_rtl_obj_find_file(rtems_rtl_obj_t *obj, const char *name)
Find an object file on disk that matches the name.
Definition: rtl-obj.c:365
void rtems_rtl_obj_erase_sections(rtems_rtl_obj_t *obj)
Erase the object file descriptor's sections.
Definition: rtl-obj.c:444
void rtems_rtl_obj_run_ctors(rtems_rtl_obj_t *obj)
Invoke the constructors the object has.
Definition: rtl-obj.c:928
link map structure will be used for GDB support.
Definition: link_elf.h:42
bool rtems_rtl_obj_unload(rtems_rtl_obj_t *obj)
Unload the object file, erasing all symbols and releasing all memory.
Definition: rtl-obj.c:1245
uint32_t rtems_rtl_obj_data_alignment(const rtems_rtl_obj_t *obj)
The data section alignment for the object file.
Definition: rtl-obj.c:563
const char * aname
The archive name containing the object.
Definition: rtl-obj.h:165
bool rtems_rtl_match_name(rtems_rtl_obj_t *obj, const char *name)
Check of the name matches the object file's object name.
Definition: rtl-obj.c:349
void rtems_rtl_obj_synchronize_cache(rtems_rtl_obj_t *obj)
Synchronize caches to make code visible to CPU(s)
Definition: rtl-obj.c:635
rtems_rtl_loader_format_t *(* rtems_rtl_loader_sig)(void)
The type of the format loader signature handler.
Definition: rtl-obj.h:74
rtems_rtl_loader_check check
The check handler.
Definition: rtl-obj.h:81
bool(* rtems_rtl_obj_sect_handler_t)(rtems_rtl_obj_t *obj, int fd, rtems_rtl_obj_sect_t *sect, void *data)
A section handler is called once for each section that needs to be processed by this handler...
Definition: rtl-obj.h:214
struct rtems_rtl_loader_format_s rtems_rtl_loader_format_t
Loader format definition.
Definition: nfs_prot.h:234
rtems_rtl_loader_sig signature
The loader's signature.
Definition: rtl-obj.h:84
struct rtems_rtl_loader_table_s rtems_rtl_loader_table_t
Table for supported loadable formats.
bool rtems_rtl_obj_load_symbols(rtems_rtl_obj_t *obj, int fd, rtems_rtl_obj_sect_handler_t handler, void *data)
Load the symbols from the object file.
Definition: rtl-obj.c:661
size_t rtems_rtl_obj_const_size(const rtems_rtl_obj_t *obj)
The const section size.
Definition: rtl-obj.c:533
const char * fname
The file name for the object.
Definition: rtl-obj.h:162
size_t rtems_rtl_obj_eh_size(const rtems_rtl_obj_t *obj)
The eh section size.
Definition: rtl-obj.c:545
size_t rtems_rtl_obj_data_size(const rtems_rtl_obj_t *obj)
The data section size.
Definition: rtl-obj.c:557
rtems_rtl_loader_unload unload
The unloader.
Definition: rtl-obj.h:83
void rtems_rtl_obj_run_dtors(rtems_rtl_obj_t *obj)
Invoke the destructors the object has.
Definition: rtl-obj.c:934
bool(* rtems_rtl_loader_check)(rtems_rtl_obj_t *obj, int fd)
The type of the format loader check handler.
Definition: rtl-obj.h:56
bool rtems_rtl_obj_load(rtems_rtl_obj_t *obj)
Load the object file, reading all sections into memory, symbols and performing any relocation fixups...
Definition: rtl-obj.c:1194