/[tinycc]/tinycc/tccelf.c
ViewVC logotype

Diff of /tinycc/tccelf.c

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

revision 1.16 by bellard, Thu May 29 22:52:53 2003 UTC revision 1.17 by bellard, Sun Jul 20 19:19:59 2003 UTC
# Line 154  static int find_elf_sym(Section *s, cons Line 154  static int find_elf_sym(Section *s, cons
154  }  }
155    
156  /* return elf symbol value or error */  /* return elf symbol value or error */
157  void *tcc_get_symbol(TCCState *s, const char *name)  int tcc_get_symbol(TCCState *s, unsigned long *pval, const char *name)
158  {  {
159      int sym_index;      int sym_index;
160      Elf32_Sym *sym;      Elf32_Sym *sym;
161            
162      sym_index = find_elf_sym(symtab_section, name);      sym_index = find_elf_sym(symtab_section, name);
163      if (!sym_index)      if (!sym_index)
164          error("%s not defined", name);          return -1;
165      sym = &((Elf32_Sym *)symtab_section->data)[sym_index];      sym = &((Elf32_Sym *)symtab_section->data)[sym_index];
166      return (void *)sym->st_value;      *pval = sym->st_value;
167        return 0;
168    }
169    
170    void *tcc_get_symbol_err(TCCState *s, const char *name)
171    {
172        unsigned long val;
173        if (tcc_get_symbol(s, &val, name) < 0)
174            error("%s not defined", name);
175        return (void *)val;
176  }  }
177    
178  /* add an elf symbol : check if it is already defined and patch  /* add an elf symbol : check if it is already defined and patch
# Line 1383  int tcc_output_file(TCCState *s1, const Line 1392  int tcc_output_file(TCCState *s1, const
1392    
1393          /* get entry point address */          /* get entry point address */
1394          if (file_type == TCC_OUTPUT_EXE)          if (file_type == TCC_OUTPUT_EXE)
1395              ehdr.e_entry = (unsigned long)tcc_get_symbol(s1, "_start");              ehdr.e_entry = (unsigned long)tcc_get_symbol_err(s1, "_start");
1396          else          else
1397              ehdr.e_entry = text_section->sh_addr; /* XXX: is it correct ? */              ehdr.e_entry = text_section->sh_addr; /* XXX: is it correct ? */
1398      }      }

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

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