Lines Matching refs:ehdr
206 static unsigned int get_shnum(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0) in get_shnum() argument
208 if (shdr0 && !ehdr->e_shnum) in get_shnum()
211 return w2(ehdr->e_shnum); in get_shnum()
214 static void set_shnum(Elf_Ehdr *ehdr, Elf_Shdr *shdr0, unsigned int new_shnum) in set_shnum() argument
217 ehdr->e_shnum = 0; in set_shnum()
220 ehdr->e_shnum = w2(new_shnum); in set_shnum()
223 static int get_shstrndx(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0) in get_shstrndx() argument
225 if (ehdr->e_shstrndx != SHN_XINDEX) in get_shstrndx()
226 return w2(ehdr->e_shstrndx); in get_shstrndx()
231 static void find_symtab(Elf_Ehdr *const ehdr, Elf_Shdr const *shdr0, in find_symtab() argument
243 *symtab = (void *)ehdr + relhdr->sh_offset; in find_symtab()
245 *symtab_shndx = (void *)ehdr + relhdr->sh_offset; in find_symtab()
253 static int append_func(Elf_Ehdr *const ehdr, in append_func() argument
267 uint_t const old_shoff = _w(ehdr->e_shoff); in append_func()
270 Elf_Shdr *const shdr0 = (Elf_Shdr *)(old_shoff + (void *)ehdr); in append_func()
271 unsigned int const old_shnum = get_shnum(ehdr, shdr0); in append_func()
282 set_shnum(ehdr, shdr0, new_shnum); in append_func()
287 if (uwrite(old_shstr_sh_offset + (void *)ehdr, old_shstr_sh_size) < 0) in append_func()
296 if (uwrite(old_shoff + (void *)ehdr, in append_func()
337 ehdr->e_shoff = _w(new_e_shoff); in append_func()
340 if (uwrite(ehdr, sizeof(*ehdr)) < 0) in append_func()
368 Elf_Ehdr const *const ehdr, in get_sym_str_and_relp() argument
373 Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff) in get_sym_str_and_relp()
374 + (void *)ehdr); in get_sym_str_and_relp()
379 + (void *)ehdr); in get_sym_str_and_relp()
382 + (void *)ehdr); in get_sym_str_and_relp()
385 + (void *)ehdr); in get_sym_str_and_relp()
399 Elf_Ehdr const *const ehdr, in sift_rel_mcount() argument
414 get_sym_str_and_relp(relhdr, ehdr, &sym0, &str0, &relp); in sift_rel_mcount()
447 Elf_Ehdr const *const ehdr, in nop_mcount() argument
450 Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff) in nop_mcount()
451 + (void *)ehdr); in nop_mcount()
462 get_sym_str_and_relp(relhdr, ehdr, &sym0, &str0, &relp); in nop_mcount()
472 ret = make_nop((void *)ehdr, _w(shdr->sh_offset) + _w(relp->r_offset)); in nop_mcount()
491 if (ulseek((void *)relp - (void *)ehdr, SEEK_SET) < 0) in nop_mcount()
518 Elf_Ehdr const *const ehdr) in find_secsym_ndx() argument
521 + (void *)ehdr); in find_secsym_ndx()
533 if (w2(ehdr->e_machine) == EM_ARM in find_secsym_ndx()
601 static int do_func(Elf_Ehdr *const ehdr, char const *const fname, in do_func() argument
604 Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff) in do_func()
605 + (void *)ehdr); in do_func()
606 unsigned const nhdr = get_shnum(ehdr, shdr0); in do_func()
607 Elf_Shdr *const shstr = &shdr0[get_shstrndx(ehdr, shdr0)]; in do_func()
609 + (void *)ehdr); in do_func()
647 find_symtab(ehdr, shdr0, nhdr, &symtab, &symtab_shndx); in do_func()
666 ehdr); in do_func()
673 relhdr, ehdr, recsym, recval, reltype); in do_func()
679 if (nop_mcount(relhdr, ehdr, txtname) < 0) { in do_func()
686 result = append_func(ehdr, shstr, mloc0, mlocp, mrel0, mrelp, in do_func()