/[qemu]/qemu/dyngen.c
ViewVC logotype

Diff of /qemu/dyngen.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.27 by bellard, Sun Aug 10 21:38:16 2003 UTC revision 1.28 by bellard, Sun Aug 10 22:14:22 2003 UTC
# Line 86  Line 86 
86  #define elf_check_arch(x) ((x) == EM_ARM)  #define elf_check_arch(x) ((x) == EM_ARM)
87  #define ELF_USES_RELOC  #define ELF_USES_RELOC
88    
89    #elif defined(HOST_M68K)
90    
91    #define ELF_CLASS       ELFCLASS32
92    #define ELF_ARCH        EM_68K
93    #define elf_check_arch(x) ((x) == EM_68K)
94    #define ELF_USES_RELOCA
95    
96  #else  #else
97  #error unsupported CPU - please update the code  #error unsupported CPU - please update the code
98  #endif  #endif
# Line 575  void gen_code(const char *name, host_ulo Line 582  void gen_code(const char *name, host_ulo
582                                        relocs, nb_relocs);                                        relocs, nb_relocs);
583          break;          break;
584  #endif  #endif
585        case EM_68K:
586            {
587                uint8_t *p;
588                p = (void *)(p_end - 2);
589                if (p == p_start)
590                    error("empty code for %s", name);
591                // remove NOP's, probably added for alignment
592                while ((get16((uint16_t *)p) == 0x4e71) &&
593                       (p>p_start))
594                  p -= 2;
595                if (get16((uint16_t *)p) != 0x4e75)
596                    error("rts expected at the end of %s", name);
597                copy_size = p - p_start;
598            }
599            break;
600      default:      default:
601          error("unknown ELF architecture");          error("unknown ELF architecture");
602      }      }
# Line 1061  void gen_code(const char *name, host_ulo Line 1083  void gen_code(const char *name, host_ulo
1083                      }                      }
1084                  }                  }
1085                  }                  }
1086                }
1087    #elif defined(HOST_M68K)
1088                {
1089                    char name[256];
1090                    int type;
1091                    int addend;
1092                    Elf32_Sym *sym;
1093                    for(i = 0, rel = relocs;i < nb_relocs; i++, rel++) {
1094                    if (rel->r_offset >= start_offset &&
1095                        rel->r_offset < start_offset + copy_size) {
1096                        sym = &(symtab[ELFW(R_SYM)(rel->r_info)]);
1097                        sym_name = strtab + symtab[ELFW(R_SYM)(rel->r_info)].st_name;
1098                        if (strstart(sym_name, "__op_param", &p)) {
1099                            snprintf(name, sizeof(name), "param%s", p);
1100                        } else {
1101                            snprintf(name, sizeof(name), "(long)(&%s)", sym_name);
1102                        }
1103                        type = ELF32_R_TYPE(rel->r_info);
1104                        addend = get32((uint32_t *)(text + rel->r_offset)) + rel->r_addend;
1105                        switch(type) {
1106                        case R_68K_32:
1107                            fprintf(outfile, "    /* R_68K_32 RELOC, offset %x */\n", rel->r_offset) ;
1108                            fprintf(outfile, "    *(uint32_t *)(gen_code_ptr + %d) = %s + %#x;\n",
1109                                    rel->r_offset - start_offset, name, addend );
1110                            break;
1111                        case R_68K_PC32:
1112                            fprintf(outfile, "    /* R_68K_PC32 RELOC, offset %x */\n", rel->r_offset);
1113                            fprintf(outfile, "    *(uint32_t *)(gen_code_ptr + %d) = %s - (long)(gen_code_ptr + %#x) + %#x;\n",
1114                                    rel->r_offset - start_offset, name, rel->r_offset - start_offset, /*sym->st_value+*/ addend);
1115                            break;
1116                        default:
1117                            error("unsupported m68k relocation (%d)", type);
1118                        }
1119                    }
1120                    }
1121              }              }
1122  #else  #else
1123  #error unsupported CPU  #error unsupported CPU

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26