Lines Matching refs:ehdr

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