/* There is no duplicate entry, create a new one */
got_plt = (struct got_entry *)got_plt_sec->shdr->sh_addr;
got_plt[i] = emit_got_entry(val);
plt = (struct plt_entry *)plt_sec->shdr->sh_addr;
plt[i] = emit_plt_entry(val,
(unsignedlong)&plt[i],
(unsignedlong)&got_plt[i]);
staticint cmp_rela(constvoid *a, constvoid *b)
{ const Elf_Rela *x = a, *y = b; int i;
/* sort by type, symbol index and addend */
i = cmp_3way(x->r_info, y->r_info); if (i == 0)
i = cmp_3way(x->r_addend, y->r_addend); return i;
}
staticbool duplicate_rela(const Elf_Rela *rela, int idx)
{ /* * Entries are sorted by type, symbol index and addend. That means * that, if a duplicate entry exists, it must be in the preceding slot.
*/ return idx > 0 && cmp_rela(rela + idx, rela + idx - 1) == 0;
}
staticvoid count_max_entries(const Elf_Rela *relas, size_t num, unsignedint *plts, unsignedint *gots)
{ for (size_t i = 0; i < num; i++) { if (duplicate_rela(relas, i)) continue;
switch (ELF_R_TYPE(relas[i].r_info)) { case R_RISCV_CALL_PLT: case R_RISCV_PLT32:
(*plts)++; break; case R_RISCV_GOT_HI20:
(*gots)++; break; default:
unreachable();
}
}
}
staticbool rela_needs_plt_got_entry(const Elf_Rela *rela)
{ switch (ELF_R_TYPE(rela->r_info)) { case R_RISCV_CALL_PLT: case R_RISCV_GOT_HI20: case R_RISCV_PLT32: returntrue; default: returnfalse;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.