Lines Matching refs:ehdr
211 static unsigned int get_shnum(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0) in get_shnum() argument
213 if (shdr0 && !ehdr->e_shnum) in get_shnum()
216 return w2(ehdr->e_shnum); in get_shnum()
219 static void set_shnum(Elf_Ehdr *ehdr, Elf_Shdr *shdr0, unsigned int new_shnum) in set_shnum() argument
222 ehdr->e_shnum = 0; in set_shnum()
225 ehdr->e_shnum = w2(new_shnum); in set_shnum()
228 static int get_shstrndx(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0) in get_shstrndx() argument
230 if (ehdr->e_shstrndx != SHN_XINDEX) in get_shstrndx()
231 return w2(ehdr->e_shstrndx); in get_shstrndx()
236 static void find_symtab(Elf_Ehdr *const ehdr, Elf_Shdr const *shdr0, in find_symtab() argument
248 *symtab = (void *)ehdr + relhdr->sh_offset; in find_symtab()
250 *symtab_shndx = (void *)ehdr + relhdr->sh_offset; in find_symtab()
258 static int append_func(Elf_Ehdr *const ehdr, in append_func() argument
272 uint_t const old_shoff = _w(ehdr->e_shoff); in append_func()
275 Elf_Shdr *const shdr0 = (Elf_Shdr *)(old_shoff + (void *)ehdr); in append_func()
276 unsigned int const old_shnum = get_shnum(ehdr, shdr0); in append_func()
287 set_shnum(ehdr, shdr0, new_shnum); in append_func()
292 if (uwrite(old_shstr_sh_offset + (void *)ehdr, old_shstr_sh_size) < 0) in append_func()
301 if (uwrite(old_shoff + (void *)ehdr, in append_func()
342 ehdr->e_shoff = _w(new_e_shoff); in append_func()
345 if (uwrite(ehdr, sizeof(*ehdr)) < 0) in append_func()
373 Elf_Ehdr const *const ehdr, in get_sym_str_and_relp() argument
378 Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff) in get_sym_str_and_relp()
379 + (void *)ehdr); in get_sym_str_and_relp()
384 + (void *)ehdr); in get_sym_str_and_relp()
387 + (void *)ehdr); in get_sym_str_and_relp()
390 + (void *)ehdr); in get_sym_str_and_relp()
404 Elf_Ehdr const *const ehdr, in sift_rel_mcount() argument
419 get_sym_str_and_relp(relhdr, ehdr, &sym0, &str0, &relp); in sift_rel_mcount()
452 Elf_Ehdr const *const ehdr, in nop_mcount() argument
455 Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff) in nop_mcount()
456 + (void *)ehdr); in nop_mcount()
467 get_sym_str_and_relp(relhdr, ehdr, &sym0, &str0, &relp); in nop_mcount()
477 ret = make_nop((void *)ehdr, _w(shdr->sh_offset) + _w(relp->r_offset)); in nop_mcount()
496 if (ulseek((void *)relp - (void *)ehdr, SEEK_SET) < 0) in nop_mcount()
523 Elf_Ehdr const *const ehdr) in find_secsym_ndx() argument
526 + (void *)ehdr); in find_secsym_ndx()
538 if (w2(ehdr->e_machine) == EM_ARM in find_secsym_ndx()
606 static int do_func(Elf_Ehdr *const ehdr, char const *const fname, in do_func() argument
609 Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff) in do_func()
610 + (void *)ehdr); in do_func()
611 unsigned const nhdr = get_shnum(ehdr, shdr0); in do_func()
612 Elf_Shdr *const shstr = &shdr0[get_shstrndx(ehdr, shdr0)]; in do_func()
614 + (void *)ehdr); in do_func()
652 find_symtab(ehdr, shdr0, nhdr, &symtab, &symtab_shndx); in do_func()
671 ehdr); in do_func()
678 relhdr, ehdr, recsym, recval, reltype); in do_func()
684 if (nop_mcount(relhdr, ehdr, txtname) < 0) { in do_func()
691 result = append_func(ehdr, shstr, mloc0, mlocp, mrel0, mrelp, in do_func()