43 #define R_386_GLOB_DATA 6
44 #define R_386_JMP_SLOT 7
45 #define R_386_RELATIVE 8
46 #define R_386_GOTOFF 9
47 #define R_386_GOTPC 10
49 #define ELF32_R_TYPE(info) ((unsigned char)(info))
51 static char datamemory[ELFLOADER_DATAMEMORY_SIZE];
57 return (
void *)datamemory;
63 int fd = open(
"/dev/zero", O_RDWR);
64 char *mem = mmap(0, ELFLOADER_TEXTMEMORY_SIZE, PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
72 cfs_read(fd, (
unsigned char *)mem, size);
77 struct elf32_rela *rela,
char *addr)
89 type = ELF32_R_TYPE(rela->r_info);
97 addr += rela->r_addend;
100 cfs_write(fd, (
char *)&addr, 4);
104 addr -= (sectionaddress + rela->r_offset);
105 addr += rela->r_addend;
108 cfs_write(fd, (
char *)&addr, 4);
112 printf(
"elfloader-x86.c: unsupported relocation type G + A - P (%d)\n", type);
115 printf(
"elfloader-x86.c: unsupported relocation type L + A - P (%d)\n", type);
117 case R_386_GLOB_DATA:
119 printf(
"elfloader-x86.c: unsupported relocation type S (%d)\n", type);
122 printf(
"elfloader-x86.c: unsupported relocation type B + A (%d)\n", type);
125 printf(
"elfloader-x86.c: unsupported relocation type S + A - GOT (%d)\n", type);
128 printf(
"elfloader-x86.c: unsupported relocation type GOT + A - P (%d)\n", type);
131 printf(
"elfloader-x86.c: unknown type (%d)\n", type);
void elfloader_arch_relocate(int fd, unsigned int sectionoffset, char *sectionaddr, struct elf32_rela *rela, char *addr)
Perform a relocation.
cfs_offset_t cfs_seek(int fd, cfs_offset_t offset, int whence)
Seek to a specified position in an open file.
Header file for the architecture specific parts of the Contiki ELF loader.
void * elfloader_arch_allocate_ram(int size)
Allocate RAM for a new module.
void * elfloader_arch_allocate_rom(int size)
Allocate program memory for a new module.
#define CFS_SEEK_SET
Specify that cfs_seek() should compute the offset from the beginning of the file. ...
void elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char *mem)
Write to read-only memory (for example the text segment).