plt.c revision d568f51920d5b2e0813cb5bb7e3cca10fc404623
1#include <gelf.h>
2#include "common.h"
3
4static int
5arch_plt_entry_has_stub(struct ltelf *lte, size_t off) {
6	uint16_t op = *(uint16_t *)((char *)lte->relplt->d_buf + off);
7	return op == 0x4778;
8}
9
10GElf_Addr
11arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {
12	size_t start = lte->relplt->d_size + 12;
13	size_t off = start + 20, i;
14	for (i = 0; i < ndx; i++)
15		off += arch_plt_entry_has_stub(lte, off) ? 16 : 12;
16	if (arch_plt_entry_has_stub(lte, off))
17		off += 4;
18	return lte->plt_addr + off - start;
19}
20
21void *
22sym2addr(Process *proc, struct library_symbol *sym) {
23	return sym->enter_addr;
24}
25