blob: c85ea92ec49aedcf513731c54b922edccd514c71 [file] [log] [blame]
Juan Cespedesd914a202004-11-10 00:15:33 +01001#include <gelf.h>
2#include "ltrace.h"
3#include "elf.h"
Ian Wienand9a2ad352006-02-20 22:44:45 +01004#include "debug.h"
5#include "ptrace.h"
6#include "options.h"
Juan Cespedesd914a202004-11-10 00:15:33 +01007
Ian Wienand9a2ad352006-02-20 22:44:45 +01008GElf_Addr
9arch_plt_sym_val (struct ltelf *lte, size_t ndx, GElf_Rela *rela)
Juan Cespedesd914a202004-11-10 00:15:33 +010010{
Ian Wienand9a2ad352006-02-20 22:44:45 +010011 return rela->r_offset;
Juan Cespedesd914a202004-11-10 00:15:33 +010012}
Ian Wienand9a2ad352006-02-20 22:44:45 +010013
14void * plt2addr(struct process *proc, void ** plt)
15{
16 long addr;
17
18 debug(3, 0);
19
20 if (proc->e_machine == EM_PPC || plt == 0)
21 return (void *)plt;
22
23 if (proc->pid == 0)
24 return (void *)0;
25
26 // On a PowerPC-64 system, a plt is three 64-bit words: the first is the
27 // 64-bit address of the routine. Before the PLT has been initialized, this
28 // will be 0x0. In fact, the symbol table won't have the plt's address even.
29 // Ater the PLT has been initialized, but before it has been resolved, the
30 // first word will be the address of the function in the dynamic linker that
31 // will reslove the PLT. After the PLT is resolved, this will will be the
32 // address of the routine whose symbol is in the symbol table.
33
34 addr = ptrace(PTRACE_PEEKTEXT, proc->pid, plt);
35
36 if (opt_d >= 3) {
37 xinfdump(proc->pid, plt, sizeof(void*)*3);
38 }
39
40 return (void *)addr;
41}
42