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

Diff of /qemu/dyngen.c

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

revision 1.15 by bellard, Tue May 27 23:29:48 2003 UTC revision 1.16 by bellard, Thu May 29 20:05:18 2003 UTC
# Line 178  ElfW(Sym) *symtab; Line 178  ElfW(Sym) *symtab;
178  int nb_syms;  int nb_syms;
179  char *strtab;  char *strtab;
180  /* data section */  /* data section */
181  uint8_t *data_data;  uint8_t *data_data, *sdata_data;
182  int data_shndx;  int data_shndx, sdata_shndx;
183    
184  uint16_t get16(uint16_t *p)  uint16_t get16(uint16_t *p)
185  {  {
# Line 499  void gen_code(const char *name, host_ulo Line 499  void gen_code(const char *name, host_ulo
499              for(i = 0, sym = symtab; i < nb_syms; i++, sym++) {              for(i = 0, sym = symtab; i < nb_syms; i++, sym++) {
500                  sym_name = strtab + sym->st_name;                  sym_name = strtab + sym->st_name;
501                  if (strstart(sym_name, "__op_label", &p)) {                  if (strstart(sym_name, "__op_label", &p)) {
502                        uint8_t *ptr;
503    
504                      /* test if the variable refers to a label inside                      /* test if the variable refers to a label inside
505                         the code we are generating */                         the code we are generating */
506                      if (sym->st_shndx != data_shndx)                      if (sym->st_shndx == data_shndx)
507                            ptr = data_data;
508                        else if (sym->st_shndx == sdata_shndx)
509                            ptr = sdata_data;
510                        else
511                          error("__op_labelN symbols must be in .data or .sdata section");                          error("__op_labelN symbols must be in .data or .sdata section");
512                      val = *(target_ulong *)(data_data + sym->st_value);                      val = *(target_ulong *)(ptr + sym->st_value);
513                      if (val >= start_offset && val < start_offset + copy_size) {                      if (val >= start_offset && val < start_offset + copy_size) {
514                          n = strtol(p, NULL, 10);                          n = strtol(p, NULL, 10);
515                          fprintf(outfile, "    label_offsets[%d] = %d + (gen_code_ptr - gen_code_buf);\n", n, val - start_offset);                          fprintf(outfile, "    label_offsets[%d] = %d + (gen_code_ptr - gen_code_buf);\n", n, val - start_offset);
# Line 878  int load_elf(const char *filename, FILE Line 884  int load_elf(const char *filename, FILE
884      struct elf_shdr *sec, *symtab_sec, *strtab_sec, *text_sec;      struct elf_shdr *sec, *symtab_sec, *strtab_sec, *text_sec;
885      int i, j;      int i, j;
886      ElfW(Sym) *sym;      ElfW(Sym) *sym;
887      char *shstr, *data_name;      char *shstr;
888      uint8_t *text;      uint8_t *text;
889      void *relocs;      void *relocs;
890      int nb_relocs, reloc_sh_type;      int nb_relocs, reloc_sh_type;
# Line 930  int load_elf(const char *filename, FILE Line 936  int load_elf(const char *filename, FILE
936          error("could not find .text section");          error("could not find .text section");
937      text = load_data(fd, text_sec->sh_offset, text_sec->sh_size);      text = load_data(fd, text_sec->sh_offset, text_sec->sh_size);
938    
939  #if defined(HOST_PPC)      data_shndx = -1;
940      data_name = ".sdata";      sec = find_elf_section(shdr, ehdr.e_shnum, shstr, ".data");
941  #else      if (sec) {
942      data_name = ".data";          data_shndx = sec - shdr;
943  #endif          data_data = load_data(fd, sec->sh_offset, sec->sh_size);
944      sec = find_elf_section(shdr, ehdr.e_shnum, shstr, data_name);      }
945      if (!sec)      sdata_shndx = -1;
946          error("could not find %s section", data_name);      sec = find_elf_section(shdr, ehdr.e_shnum, shstr, ".sdata");
947      data_shndx = sec - shdr;      if (sec) {
948      data_data = load_data(fd, sec->sh_offset, sec->sh_size);          sdata_shndx = sec - shdr;
949            sdata_data = load_data(fd, sec->sh_offset, sec->sh_size);
950        }
951            
952      /* find text relocations, if any */      /* find text relocations, if any */
953      nb_relocs = 0;      nb_relocs = 0;

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

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