2012-09-29 05:05:31 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <elf.h>
|
2013-07-18 23:29:44 +00:00
|
|
|
#include <endian.h>
|
2012-09-29 05:05:31 +00:00
|
|
|
|
2013-07-18 23:29:44 +00:00
|
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
|
|
#define ENDIAN_SUFFIX "el"
|
|
|
|
#else
|
|
|
|
#define ENDIAN_SUFFIX ""
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LDSO_ARCH "microblaze" ENDIAN_SUFFIX
|
2012-09-29 05:05:31 +00:00
|
|
|
|
2014-06-18 06:44:02 +00:00
|
|
|
#define TPOFF_K 0
|
2012-09-29 05:05:31 +00:00
|
|
|
|
2014-06-18 06:44:02 +00:00
|
|
|
static int remap_rel(int type)
|
2012-09-29 05:05:31 +00:00
|
|
|
{
|
|
|
|
switch(type) {
|
|
|
|
case R_MICROBLAZE_32:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_SYMBOLIC;
|
2012-09-29 05:05:31 +00:00
|
|
|
case R_MICROBLAZE_GLOB_DAT:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_GOT;
|
2012-09-29 05:05:31 +00:00
|
|
|
case R_MICROBLAZE_JUMP_SLOT:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_PLT;
|
2012-09-29 05:05:31 +00:00
|
|
|
case R_MICROBLAZE_REL:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_RELATIVE;
|
2012-09-29 05:05:31 +00:00
|
|
|
case R_MICROBLAZE_COPY:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_COPY;
|
2012-10-16 01:01:48 +00:00
|
|
|
case R_MICROBLAZE_TLSDTPMOD32:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_DTPMOD;
|
2012-10-16 01:01:48 +00:00
|
|
|
case R_MICROBLAZE_TLSDTPREL32:
|
2014-06-18 06:44:02 +00:00
|
|
|
return REL_DTPOFF;
|
2012-09-29 05:05:31 +00:00
|
|
|
}
|
2014-06-16 07:09:07 +00:00
|
|
|
return 0;
|
2012-09-29 05:05:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "syscall.h"
|
|
|
|
void __reloc_self(int c, size_t *a, size_t *dynv)
|
|
|
|
{
|
|
|
|
char dot = '.', ex = 'x';
|
|
|
|
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-09-29 05:05:31 +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_MICROBLAZE_REL)
|
|
|
|
*(size_t *)(base+a[0]) = (size_t)base + a[2];
|
|
|
|
}
|