Beispiel #1
0
void refer_symbol(symbol *sym,char *refname)
/* refer to an existing symbol with an additional name */
{
  hashdata data;
  data.ptr=sym;
  add_hashentry(symhash,refname,data);
}
Beispiel #2
0
int init_syntax()
{
  size_t i;
  hashdata data;
  dirhash=new_hashtable(0x200); /*FIXME: */
  for(i=0;i<dir_cnt;i++){
    data.idx=i;
    add_hashentry(dirhash,directives[i].name,data);
  }
  
  return 1;
}
Beispiel #3
0
Datei: vasm.c Projekt: ezrec/vasm
static void print_type(FILE *f,symbol *p)
{
    static const char *typename[] = {"???","obj","func","sect","file"};
    if(p==NULL)
        ierror(0);
    fprintf(f,"type=%s ",typename[TYPE(p)]);
}

void print_symbol(FILE *f,symbol *p)
{
    if(p==NULL)
        ierror(0);	/* this is usually an error in a cpu-backend, don't crash! */
    fprintf(f,"%s ",p->name);
    if(p->type==LABSYM)
        fprintf(f,"LAB (0x%llx) ",((unsigned long long)p->pc)&taddrmask);
    if(p->type==IMPORT)
        fprintf(f,"IMP ");
    if(p->type==EXPRESSION) {
        fprintf(f,"EXPR(");
        print_expr(f,p->expr);
        fprintf(f,") ");
    }
    if(p->flags&EXPORT)
        fprintf(f,"EXPORT ");
    if(p->flags&COMMON)
        fprintf(f,"COMMON ");
    if(p->flags&WEAK)
        fprintf(f,"WEAK ");
    if(TYPE(p))
        print_type(f,p);
    if(p->size) {
        fprintf(f,"size=");
        print_expr(f,p->size);
        fprintf(f," ");
    }
    if(p->align)
        fprintf(f,"align=%lu ",(unsigned long)p->align);
    if(p->sec)
        fprintf(f,"sec=%s ",p->sec->name);
}

void add_symbol(symbol *p)
{
    hashdata data;
    p->next=first_symbol;
    first_symbol=p;
    data.ptr=p;
    add_hashentry(symhash,p->name,data);
}
Beispiel #4
0
int init_syntax()
{
  size_t i;
  hashdata data;
  dirhash=new_hashtable(0x200); /*FIXME: */
  for(i=0;i<dir_cnt;i++){
    data.idx=i;
    add_hashentry(dirhash,directives[i].name,data);
  }

#if defined(VASM_CPU_X86)
  current_pc_char = '.';
#endif  
  cond[0] = 1;
  clev = ifnesting = 0;
  return 1;
}
Beispiel #5
0
int init_syntax()
{
  size_t i;
  hashdata data;

  dirhash = new_hashtable(0x200);
  for (i=0; i<dir_cnt; i++) {
    data.idx = i;
    add_hashentry(dirhash,directives[i].name,data);
  }
  
  cond_init();
  current_pc_char = '*';
  esc_sequences = 1;

  /* assertion errors are only a warning */
  modify_gen_err(WARNING,47,0);

  return 1;
}
Beispiel #6
0
Datei: vasm.c Projekt: ezrec/vasm
static int init_main(void)
{
    size_t i;
    char *last;
    hashdata data;
    mnemohash=new_hashtable(MNEMOHTABSIZE);
    i=0;
    while(i<mnemonic_cnt) {
        data.idx=i;
        last=mnemonics[i].name;
        add_hashentry(mnemohash,mnemonics[i].name,data);
        do {
            i++;
        } while(i<mnemonic_cnt&&!strcmp(last,mnemonics[i].name));
    }
    if(DEBUG) {
        if(mnemohash->collisions)
            printf("*** %d mnemonic collisions!!\n",mnemohash->collisions);
    }
    symhash=new_hashtable(SYMHTABSIZE);
    new_include_path(".");
    taddrmask=MAKEMASK(bytespertaddr<<3);
    return 1;
}
Beispiel #7
0
static void print_type(FILE *f,symbol *p)
{
  static const char *typename[] = {"???","obj","func","sect","file"};
  int t;

  if (p == NULL)
    ierror(0);
  t = TYPE(p);
  fprintf(f,"type=%s ",typename[t<=TYPE_LAST?t:0]);
}


void print_symbol(FILE *f,symbol *p)
{
  if (p==NULL)
    ierror(0);	/* this is usually an error in a cpu-backend, don't crash! */

  fprintf(f,"%s ",p->name);

  if (p->type==LABSYM)
    fprintf(f,"LAB (0x%llx) ",ULLTADDR(p->pc));
  if (p->type==IMPORT)
    fprintf(f,"IMP ");
  if (p->type==EXPRESSION){
    fprintf(f,"EXPR(");
    print_expr(f,p->expr);
    fprintf(f,") ");
  }
  if (!(p->flags&(USED|VASMINTERN)))
    fprintf(f,"UNUSED ");
  if (p->flags&VASMINTERN)
    fprintf(f,"INTERNAL ");
  if (p->flags&EXPORT)
    fprintf(f,"EXPORT ");
  if (p->flags&COMMON)
    fprintf(f,"COMMON ");
  if (p->flags&WEAK)
    fprintf(f,"WEAK ");
  if (p->flags&LOCAL)
    fprintf(f,"LOCAL ");
  if (p->flags&PROTECTED)
    fprintf(f,"PROT ");
  if (p->flags&REFERENCED)
    fprintf(f,"REF ");
  if (p->flags&ABSLABEL)
    fprintf(f,"ABS ");
  if (p->flags&EQUATE)
    fprintf(f,"EQU ");
  if (p->flags&REGLIST)
    fprintf(f,"REGL ");
  if (TYPE(p))
    print_type(f,p);
  if (p->size){
    fprintf(f,"size=");
    print_expr(f,p->size);
    fprintf(f," ");
  }
  if (p->align)
    fprintf(f,"align=%lu ",(unsigned long)p->align);
  if (p->sec)
    fprintf(f,"sec=%s ",p->sec->name);
}


char *get_bind_name(symbol *p)
{
  if (p->flags&EXPORT)
    return "global";
  else if (p->flags&WEAK)
    return "weak";
  else if (p->flags&LOCAL)
    return "local";
  return "unknown";
}


void add_symbol(symbol *p)
{
  hashdata data;

  p->next = first_symbol;
  first_symbol = p;
  data.ptr = p;
  add_hashentry(symhash,p->name,data);
}