38 char * p, * start, * s;
44 while (*p != 0 && *p != delimiter)
61 char * path = (
char *)
format (0,
"%s/%s%c", dir, file, 0);
65 yes = (stat (path, &s) >= 0
66 && S_ISREG (s.st_mode)
67 && 0 != (s.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)));
82 if (file[0] ==
'.' || file[0] ==
'/')
92 if (i < vec_len (ps.
path))
93 result = (
char *)
format (0,
"%s/%s%c", ps.
path[i], file);
109 uword mmap_length = 0;
115 fd = open (file_name, 0);
122 if (fstat (fd, &fd_stat) < 0)
127 mmap_length = fd_stat.st_size;
129 data = mmap (0, mmap_length, PROT_READ, MAP_SHARED, fd, 0);
136 error =
elf_parse (em, data, mmap_length);
143 uword section_name_start_len = strlen (section_name_start);
153 if (memcmp (name, section_name_start, section_name_start_len))
156 name += section_name_start_len;
162 name =
format (0,
"%s%c", name, 0);
171 b->
lo = link_address + s->
header.exec_address;
196 if (s->
header.type != ELF_SECTION_STRING_TABLE)
207 munmap (data, mmap_length);
219 char * name = (
char *) info->dlpi_name;
220 void *
addr = (
void *) info->dlpi_addr;
223 is_main = strlen (name) == 0;
297 if (by_address >= x->value && by_address < x->value + x->size)
347 s =
format (s,
"%s + 0x%wx",
349 address - sym.
symbol.value);
352 s =
format (s,
"0x%wx", address);
clib_elf_section_t * sections
sll srl srl sll sra u16x4 i
static int file_exists_and_is_executable(char *dir, char *file)
#define clib_error(format, args...)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define CLIB_ELF_SECTION_ADD_PREFIX(n)
#define hash_set_mem(h, key, value)
#define clib_error_report(e)
void elf_parse_symbols(elf_main_t *em)
always_inline u8 * elf_section_name(elf_main_t *em, elf_section_t *s)
uword clib_elf_symbol_by_address(uword by_address, clib_elf_symbol_t *s)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
clib_elf_section_bounds_t * bounds
static clib_error_t * clib_elf_parse_file(clib_elf_main_t *cem, char *file_name, void *link_address)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static char ** split_string(char *string, u8 delimiter)
elf_symbol_table_t * symbol_tables
static uword pointer_to_uword(const void *p)
#define hash_create_string(elts, value_bytes)
#define clib_error_return_unix(e, args...)
always_inline void path_search_free(path_search_t *p)
#define vec_free(V)
Free vector's memory (no header).
always_inline void elf_main_free(elf_main_t *em)
void clib_elf_main_init(char *exec_path)
always_inline u8 * elf_symbol_name(elf_symbol_table_t *t, elf64_symbol_t *sym)
uword clib_elf_symbol_by_name(char *by_name, clib_elf_symbol_t *s)
static char * path_search(char *file)
clib_elf_section_bounds_t * clib_elf_get_section_bounds(char *name)
static uword symbol_by_address_or_name(char *by_name, uword by_address, clib_elf_symbol_t *s)
#define vec_elt(v, i)
Get vector value at index i.
u8 * format_clib_elf_symbol(u8 *s, va_list *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * elf_parse(elf_main_t *em, void *data, uword data_bytes)
format_function_t format_elf_symbol
#define hash_get_mem(h, key)
u8 * format_clib_elf_symbol_with_address(u8 *s, va_list *args)
elf64_section_header_t header
#define vec_foreach(var, vec)
Vector iterator.
static int add_section(struct dl_phdr_info *info, size_t size, void *opaque)
static clib_elf_main_t clib_elf_main