|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
40 #include <sys/types.h>
87 if (g->
header.type == ELF_SEGMENT_INTERP)
94 if (g->
header.memory_size < 1 + strlen (interp))
95 return clib_error_return (0,
"given interpreter does not fit; must be less than %d bytes (`%s' given)",
96 g->
header.memory_size, interp);
119 case ELF_DYNAMIC_ENTRY_RPATH:
120 case ELF_DYNAMIC_ENTRY_RUN_PATH:
132 e_end.type = ELF_DYNAMIC_ENTRY_END;
152 case ELF_SECTION_DYNAMIC:
167 int old_len, new_len = strlen (new_rpath);
174 case ELF_DYNAMIC_ENTRY_RPATH:
175 case ELF_DYNAMIC_ENTRY_RUN_PATH:
176 old_rpath = (
char *) new_string_table + e->data;
177 old_len = strlen (old_rpath);
178 if (old_len < new_len)
180 new_rpath, old_rpath);
181 strcpy (old_rpath, new_rpath);
206 case ELF_SECTION_DYNAMIC:
223 int ifd = -1, ofd = -1;
226 u64 mmap_length = 0,
i;
229 u64 offset0 = 0, offset1 = 0;
231 int fix_in_place = 0;
243 if (fstat (ifd, &fd_stat) < 0)
249 if (!(fd_stat.st_mode & S_IFREG))
255 mmap_length = fd_stat.st_size;
264 idp = mmap (0, mmap_length, PROT_READ | PROT_WRITE, MAP_SHARED,
267 idp = mmap (0, mmap_length, PROT_READ | PROT_WRITE, MAP_PRIVATE,
276 if (idp[0] != 0x7f || idp[1] !=
'E' || idp[2] !=
'L' || idp[3] !=
'F')
285 for (
i = 0;
i < mmap_length;
i++)
299 if (in_run && run_length >= 16)
302 offset0 = (
i - run_length);
303 else if (offset1 == 0)
305 offset1 = (
i - run_length);
323 clib_warning (
"offset0 %lld (0x%llx), offset1 %lld (0x%llx)",
324 offset0, offset0, offset1, offset1);
327 if (offset0 && offset1)
347 if (fix_in_place == 0)
349 ofd = open (tm->
output_file, O_RDWR | O_CREAT | O_TRUNC, 0644);
356 if (write (ofd, idp, mmap_length) != mmap_length)
361 if (mmap_length > 0 && idp)
362 munmap (idp, mmap_length);
371 int main (
int argc,
char * argv[])
395 else if (
unformat (&
i,
"verbose-symbols"))
397 else if (
unformat (&
i,
"verbose-relocations"))
399 else if (
unformat (&
i,
"verbose-dynamic"))
403 else if (
unformat (&
i,
"allow-elf-shared"))
format_function_t format_elf_main
#define clib_memcpy(d, s, n)
static uword pointer_to_uword(const void *p)
static void elf_main_free(elf_main_t *em)
#define vec_end(v)
End (last data address) of vector.
#define clib_error_return(e, args...)
#define FORMAT_ELF_MAIN_SYMBOLS
#define clib_error_report(e)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_dup(V)
Return copy of vector (no header, no alignment)
u32 dynamic_string_table_section_index
__clib_export clib_error_t * elf_get_section_by_start_address(elf_main_t *em, uword start_address, elf_section_t **result)
sll srl srl sll sra u16x4 i
__clib_export clib_error_t * elf_write_file(elf_main_t *em, char *file_name)
u8 * dynamic_string_table
#define FORMAT_ELF_MAIN_RELOCATIONS
__clib_export void elf_set_dynamic_entries(elf_main_t *em)
elf64_segment_header_t header
elf64_section_header_t header
#define vec_free(V)
Free vector's memory (no header).
static void elf_set_section_contents(elf_main_t *em, uword section_index, void *new_contents, uword n_content_bytes)
__clib_export clib_error_t * elf_read_file(elf_main_t *em, char *file_name)
#define vec_foreach(var, vec)
Vector iterator.
#define clib_error_return_unix(e, args...)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
elf64_dynamic_entry_t * dynamic_entries
elf_first_header_t first_header
#define clib_warning(format, args...)
#define FORMAT_ELF_MAIN_DYNAMIC
#define vec_bytes(v)
Number of data bytes in vector.