2012-11-09 22:36:55 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <elf.h>
|
|
|
|
|
2013-07-26 07:10:11 +00:00
|
|
|
#define LDSO_ARCH "powerpc"
|
2012-11-09 22:36:55 +00:00
|
|
|
|
2014-06-18 06:44:02 +00:00
|
|
|
#define TPOFF_K (-0x7000)
|
2012-11-09 22:36:55 +00:00
|
|
|
|
2014-06-18 06:44:02 +00:00
|
|
|
static int remap_rel(int type)
|
2012-11-09 22:36:55 +00:00
|
|
|
{
|
|
|
|
switch(type) {
|
2014-06-18 06:44:02 +00:00
|
|
|
case R_PPC_ADDR32:
|
|
|
|
return REL_SYMBOLIC;
|
2012-11-09 22:36:55 +00:00
|
|
|
case R_PPC_GLOB_DAT:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_GOT;
|
2012-11-09 22:36:55 +00:00
|
|
|
case R_PPC_JMP_SLOT:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_PLT;
|
2012-11-09 22:36:55 +00:00
|
|
|
case R_PPC_RELATIVE:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_RELATIVE;
|
|
|
|
case R_PPC_COPY:
|
|
|
|
return REL_COPY;
|
2012-11-17 03:22:34 +00:00
|
|
|
case R_PPC_DTPMOD32:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_DTPMOD;
|
2012-11-17 03:22:34 +00:00
|
|
|
case R_PPC_DTPREL32:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_DTPOFF;
|
2012-11-17 03:22:34 +00:00
|
|
|
case R_PPC_TPREL32:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_TPOFF;
|
2012-11-09 22:36:55 +00:00
|
|
|
}
|
2014-06-16 07:09:07 +00:00
|
|
|
return 0;
|
2012-11-09 22:36:55 +00:00
|
|
|
}
|
2012-11-17 03:22:34 +00:00
|
|
|
|
|
|
|
void __reloc_self(int c, size_t *a, size_t *dynv)
|
|
|
|
{
|
|
|
|
char *base;
|
|
|
|
size_t t[20], n;
|
|
|
|
for (a+=c+1; *a; a++);
|
|
|
|
for (a++; *a; a+=2) if (*a<20) t[*a] = a[1];
|
|
|
|
base = (char *)t[AT_BASE];
|
2013-09-15 02:00:32 +00:00
|
|
|
if (!base) base = (char *)(t[AT_PHDR] & -t[AT_PAGESZ]);
|
2012-11-17 03:22:34 +00:00
|
|
|
for (a=dynv; *a; a+=2) if (*a<20) t[*a] = a[1];
|
|
|
|
n = t[DT_RELASZ];
|
|
|
|
for (a=(void *)(base+t[DT_RELA]); n; a+=3, n-=12)
|
|
|
|
if (a[1]%256 == R_PPC_RELATIVE)
|
|
|
|
*(size_t *)(base+a[0]) = (size_t)base + a[2];
|
|
|
|
}
|