mips栈桢寄存器偏移没有规定,所以有这么个结构。
来自ECOFF 标准phr格式.动态生成。
/* The structure of the runtime procedure descriptor created by the
loader for use by the static exception system. */
typedef struct runtime_pdr {
bfd_vma adr; /* Memory address of start of procedure. */
long regmask; /* Save register mask. */
long regoffset; /* Save register offset. */
long fregmask; /* Save floating point register mask. */
long fregoffset; /* Save floating point register offset. */
long frameoffset; /* Frame size. */
short framereg; /* Frame pointer register. */
short pcreg; /* Offset or reg of return pc. */
long irpss; /* Index into the runtime string table. */
long reserved;
struct exception_info *exception_info;/* Pointer to exception array. */
} RPDR, *pRPDR;
/////////////////////
bool mips 的elf格式文件里面有一个pdr section
每段32字节,就是和上面有关的内容,包含至pcreg,每个字段都是4字节
Contents of section .pdr:
0000 20000920 40000000 fffffff8 00000000 .. @...........
0010 00000000 00000010 0000001e 0000001f ................
0020 2000094c d0000000 fffffff8 00000000 ..L............
0030 00000000 00000020 0000001e 0000001f ....... ........
0040 200009a0 00000000 00000000 00000000 ...............
0050 00000000 00000000 0000001d 0000001f ................
0060 200009a8 903f0000 fffffff8 00000000 ....?..........
0070 00000000 00000040 0000001d 0000001f .......@........
/////////////////////
/////////////////////
static bfd_boolean mips_elf_create_procedure_table ()函数里面生成,很麻烦~~
{
...
//存在epdr
if (! _bfd_ecoff_get_accumulated_pdr (handle, (bfd_byte *) epdr))
...
rp = rpdr = bfd_malloc (size * count);
...
for (i = 0; i < (unsigned long) count; i++, rp++)
{
(*swap->swap_pdr_in) (abfd, epdr + i, &pdr);
(*swap->swap_sym_in) (abfd, &esym[pdr.isym], &sym);
//存在rp==rpdr里面
rp->adr = sym.value;
rp->regmask = pdr.regmask;
....
....
rp->framereg = pdr.framereg;
rp->pcreg = pdr.pcreg;
rp->irpss = sindex;
sv[i] = ss + sym.iss;
sindex += strlen (sv[i]) + 1;
}
...
erp = rtproc;
...
for (i = 0; i < count; i++)
{ //存在rtproc里面
ecoff_swap_rpdr_out (abfd, rpdr + i, erp + i);
......
}
最后都由contents存着
s->contents = rtproc;
contents居然是一个void* 怎么解释都可以~~
/////////////////////
几个有趣的拷贝函数
ecoff_swap_pdr_in
ecoff_swap_pdr_out
ecoff_swap_rpdr_out
////////////////////
typedef struct {
unsigned char st_name[4]; /* Symbol name, index in string tbl */
unsigned char st_value[4]; /* Value of the symbol */
unsigned char st_size[4]; /* Associated symbol size */
unsigned char st_info[1]; /* Type and binding attributes */
unsigned char st_other[1]; /* No defined meaning, 0 */
unsigned char st_shndx[2]; /* Associated section index */
} Elf32_External_Sym;
typedef struct {
unsigned char st_name[4]; /* Symbol name, index in string tbl */
unsigned char st_info[1]; /* Type and binding attributes */
unsigned char st_other[1]; /* No defined meaning, 0 */
unsigned char st_shndx[2]; /* Associated section index */
unsigned char st_value[8]; /* Value of the symbol */
unsigned char st_size[8]; /* Associated symbol size */
} Elf64_External_Sym;
阅读(1502) | 评论(0) | 转发(0) |