/* * Find/Create a global symbol entry. * * S xxxxxx Defnnnn * | | | * | | `-- sp->s_addr * | `----- sp->s_type * `------------ sp->s_id * */ struct sym * newsym() { a_uint ev; int c, i, nsym; struct sym *tsp; struct sym **s; char id[NCPS]; if (headp == NULL) { fprintf(stderr, "No header defined\n"); lkexit(ER_FATAL); } /* * Create symbol entry */ getid(id, -1); tsp = lkpsym(id, 1); c = getnb();get();get(); if (c == 'R') { tsp->s_type |= S_REF; if (eval()) { fprintf(stderr, "Non zero S_REF\n"); lkerr++; } } else if (c == 'D') { ev = eval(); if (tsp->s_type & S_DEF) { if (tsp->s_addr != ev) { fprintf(stderr, "Multiple definition of %s\n", id); lkerr++; } } else { /* * Set value and area extension link. */ tsp->s_addr = ev; tsp->s_axp = axp; tsp->s_type |= S_DEF; tsp->m_id = hp->m_id; } } else { fprintf(stderr, "Invalid symbol type %c for %s\n", c, id); lkexit(ER_FATAL); } /* * Place pointer in header symbol list */ nsym = hp->h_nsym; s = hp->s_list; for (i=0; i < nsym ;++i) { if (s[i] == NULL) { s[i] = tsp; return(tsp); } } fprintf(stderr, "Header symbol list overflow\n"); lkexit(ER_FATAL); return(NULL); }
/*JCF: Creates some of the default areas so they are allocated in the right order.*/ void Areas51 (void) { char * rel[] = { "XH", "H 7 areas 0 global symbols", "A _CODE size 0 flags 0", /*Each .rel has one, so...*/ "A REG_BANK_0 size 0 flags 4", /*Register banks are overlayable*/ "A REG_BANK_1 size 0 flags 4", "A REG_BANK_2 size 0 flags 4", "A REG_BANK_3 size 0 flags 4", "A BSEG size 0 flags 80", /*BSEG must be just before BITS*/ "A BSEG_BYTES size 0 flags 0", /*Size will be obtained from BSEG in lnkarea()*/ "" }; char * rel2[] = { "XH", "H C areas 0 global symbols", "A _CODE size 0 flags 0", /*Each .rel has one, so...*/ "A REG_BANK_0 size 0 flags 4", /*Register banks are overlayable*/ "A REG_BANK_1 size 0 flags 4", "A REG_BANK_2 size 0 flags 4", "A REG_BANK_3 size 0 flags 4", "A BSEG size 0 flags 80", /*BSEG must be just before BITS*/ "A BSEG_BYTES size 0 flags 0", /*Size will be obtained from BSEG in lnkarea()*/ "A BIT_BANK size 0 flags 4", /*Bit register bank is overlayable*/ "A DSEG size 0 flags 0", "A OSEG size 0 flags 4", "A ISEG size 0 flags 0", "A SSEG size 0 flags 4", "" }; int j; struct sym * sp; if (packflag) { for (j = 0; rel2[j][0] != 0; j++) { ip = rel2[j]; link_main(); } } else { for (j = 0; rel[j][0] != 0; j++) { ip = rel[j]; link_main(); } } /*Set the start address of the default areas:*/ for (ap = areap; ap; ap = ap->a_ap) { /**/ if (!strcmp(ap->a_id, "REG_BANK_0")) { ap->a_addr = 0x00; ap->a_type = 1; } else if (!strcmp(ap->a_id, "REG_BANK_1")) { ap->a_addr = 0x08; ap->a_type = 1; } else if (!strcmp(ap->a_id, "REG_BANK_2")) { ap->a_addr = 0x10; ap->a_type = 1; } else if (!strcmp(ap->a_id, "REG_BANK_3")) { ap->a_addr = 0x18; ap->a_type = 1; } else if (!strcmp(ap->a_id, "BSEG_BYTES")) { ap->a_addr = 0x20; ap->a_type = 1; } else if (TARGET_IS_8051 && !strcmp(ap->a_id, "SSEG")) { if (stacksize) ap->a_axp->a_size = stacksize; } } if (TARGET_IS_8051) { sp = lkpsym("l_IRAM", 1); sp->s_addr = ((iram_size>0) && (iram_size<=0x100)) ? iram_size : 0x0100; sp->s_axp = NULL; sp->s_type |= S_DEF; } }