blob: fb98d7b4e2a74f78980cf32bc7a78ae3f8034371 [file] [log] [blame]
Juan Cespedesd914a202004-11-10 00:15:33 +01001#include <gelf.h>
Petr Machata366c2f42012-02-09 19:34:36 +01002#include "proc.h"
Juan Cespedesf7281232009-06-25 16:11:21 +02003#include "common.h"
Juan Cespedesd914a202004-11-10 00:15:33 +01004
Zach Welchd568f512010-10-08 14:44:16 -07005static int
6arch_plt_entry_has_stub(struct ltelf *lte, size_t off) {
7 uint16_t op = *(uint16_t *)((char *)lte->relplt->d_buf + off);
8 return op == 0x4778;
9}
10
Juan Cespedesf1350522008-12-16 18:19:58 +010011GElf_Addr
12arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {
Zach Welchd568f512010-10-08 14:44:16 -070013 size_t start = lte->relplt->d_size + 12;
14 size_t off = start + 20, i;
15 for (i = 0; i < ndx; i++)
16 off += arch_plt_entry_has_stub(lte, off) ? 16 : 12;
17 if (arch_plt_entry_has_stub(lte, off))
18 off += 4;
19 return lte->plt_addr + off - start;
Ian Wienand9a2ad352006-02-20 22:44:45 +010020}
21
Juan Cespedesf1350522008-12-16 18:19:58 +010022void *
Juan Cespedesa8909f72009-04-28 20:02:41 +020023sym2addr(Process *proc, struct library_symbol *sym) {
Paul Gilliam76c61f12006-06-14 06:55:21 +020024 return sym->enter_addr;
Juan Cespedesd914a202004-11-10 00:15:33 +010025}