44 #define R_386_GLOB_DATA 6
45 #define R_386_JMP_SLOT 7
46 #define R_386_RELATIVE 8
47 #define R_386_GOTOFF 9
48 #define R_386_GOTPC 10
50 #define ELF32_R_TYPE(info) ((unsigned char)(info))
52 static char datamemory[ELFLOADER_DATAMEMORY_SIZE];
58 return (
void *)datamemory;
64 int fd = open(
"/dev/zero", O_RDWR);
65 char *mem = mmap(0, ELFLOADER_TEXTMEMORY_SIZE, PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
73 cfs_read(fd, (
unsigned char *)mem, size);
78 struct elf32_rela *rela,
char *addr)
90 type = ELF32_R_TYPE(rela->r_info);
98 addr += rela->r_addend;
101 cfs_write(fd, (
char *)&addr, 4);
105 addr -= (sectionaddress + rela->r_offset);
106 addr += rela->r_addend;
109 cfs_write(fd, (
char *)&addr, 4);
113 printf(
"elfloader-x86.c: unsupported relocation type G + A - P (%d)\n", type);
116 printf(
"elfloader-x86.c: unsupported relocation type L + A - P (%d)\n", type);
118 case R_386_GLOB_DATA:
120 printf(
"elfloader-x86.c: unsupported relocation type S (%d)\n", type);
123 printf(
"elfloader-x86.c: unsupported relocation type B + A (%d)\n", type);
126 printf(
"elfloader-x86.c: unsupported relocation type S + A - GOT (%d)\n", type);
129 printf(
"elfloader-x86.c: unsupported relocation type GOT + A - P (%d)\n", type);
132 printf(
"elfloader-x86.c: unknown type (%d)\n", type);