7 #define PRINTF(...) printf(__VA_ARGS__)
9 #define PRINTF(...) do {} while (0)
12 #define ELF32_R_TYPE(info) ((unsigned char)(info))
17 #define R_ARM_THM_CALL 10
24 unsigned int sectionoffset,
26 struct elf32_rela *rela,
char *addr)
30 type = ELF32_R_TYPE(rela->r_info);
40 cfs_read(input_fd, (
char*)&addend, 4);
42 elfloader_output_write_segment(output,(
char*) &addr, 4);
43 PRINTF(
"%p: addr: %p\n", sectionaddr +rela->r_offset,
52 cfs_read(input_fd, (
char*)instr, 4);
56 base = sectionaddr + (rela->r_offset + 4);
58 if (((instr[1]) & 0xe800) == 0xe800) {
60 if (((uint32_t)addr) & 0x1) {
64 #if defined(__ARM_ARCH_4T__)
74 if ((instr[1] & 0x1800) == 0x0800) {
75 addr = (
char*)((((uint32_t)addr) & 0xfffffffd)
76 | (((uint32_t)base) & 0x00000002));
78 offset = addr - (sectionaddr + (rela->r_offset + 4));
79 if (offset < -(1<<22) || offset >= (1<<22)) {
80 PRINTF(
"elfloader-arm.c: offset %d too large for relative call\n",
84 instr[0] = (instr[0] & 0xf800) | ((offset>>12)&0x07ff);
85 instr[1] = (instr[1] & 0xf800) | ((offset>>1)&0x07ff);
86 elfloader_output_write_segment(output, (
char*)instr, 4);
92 PRINTF(
"elfloader-arm.c: unsupported relocation type %d\n", type);