예제 #1
0
파일: labels.c 프로젝트: zoro0312/Liux
void define_common(char *label, int32_t segment, int32_t size, char *special)
{
    union label *lptr;

    lptr = find_label(label, 1);
    if (!lptr)
        return;
    if ((lptr->defn.is_global & DEFINED_BIT) &&
            (passn == 1 || !(lptr->defn.is_global & COMMON_BIT))) {
        nasm_error(ERR_NONFATAL, "symbol `%s' redefined", label);
        return;
    }
    lptr->defn.is_global |= DEFINED_BIT|COMMON_BIT;

    if (!islocalchar(label[0])) {
        prevlabel = lptr->defn.label;
    } else {
        nasm_error(ERR_NONFATAL, "attempt to define a local label as a "
                   "common variable");
        return;
    }

    lptr->defn.segment = segment;
    lptr->defn.offset = 0;

    if (pass0 == 0)
        return;

    ofmt->symdef(lptr->defn.label, segment, size, 2,
                 special ? special : lptr->defn.special);
    ofmt->current_dfmt->debug_deflabel(lptr->defn.label, segment, size, 2,
                                       special ? special : lptr->defn.special);
}
예제 #2
0
파일: labels.c 프로젝트: sunank200/ATOM-OS
void define_common(char *label, long segment, long size, char *special,
                   struct ofmt *ofmt, efunc error)
{
    union label *lptr;

    lptr = find_label(label, 1);
    if (lptr->defn.is_global & DEFINED_BIT) {
        error(ERR_NONFATAL, "symbol `%s' redefined", label);
        return;
    }
    lptr->defn.is_global |= DEFINED_BIT;

    if (!islocalchar(label[0])) /* not local, but not special either */
        prevlabel = lptr->defn.label;
    else
        error(ERR_NONFATAL, "attempt to define a local label as a "
              "common variable");

    lptr->defn.segment = segment;
    lptr->defn.offset = 0;

    ofmt->symdef(lptr->defn.label, segment, size, 2,
                 special ? special : lptr->defn.special);
    ofmt->current_dfmt->debug_deflabel(lptr->defn.label, segment, size, 2,
                                       special ? special : lptr->defn.
                                       special);
}
예제 #3
0
파일: labels.c 프로젝트: zoro0312/Liux
void define_label(char *label, int32_t segment, int64_t offset, char *special,
                  bool is_norm, bool isextrn)
{
    union label *lptr;
    int exi;

#ifdef DEBUG
#if DEBUG<3
    if (!strncmp(label, "debugdump", 9))
#endif
        nasm_error(ERR_DEBUG, "define_label (%s, %"PRIx32", %"PRIx64", %s, %d, %d)",
                   label, segment, offset, special, is_norm, isextrn);
#endif
    lptr = find_label(label, 1);
    if (!lptr)
        return;
    if (lptr->defn.is_global & DEFINED_BIT) {
        nasm_error(ERR_NONFATAL, "symbol `%s' redefined", label);
        return;
    }
    lptr->defn.is_global |= DEFINED_BIT;
    if (isextrn)
        lptr->defn.is_global |= EXTERN_BIT;

    if (!islocalchar(label[0]) && is_norm) {
        /* not local, but not special either */
        prevlabel = lptr->defn.label;
    } else if (islocal(label) && !*prevlabel) {
        nasm_error(ERR_NONFATAL, "attempt to define a local label before any"
                   " non-local labels");
    }

    lptr->defn.segment = segment;
    lptr->defn.offset = offset;
    lptr->defn.is_norm = (!islocalchar(label[0]) && is_norm);

    if (pass0 == 1 || (!is_norm && !isextrn && (segment > 0) && (segment & 1))) {
        exi = !!(lptr->defn.is_global & GLOBAL_BIT);
        if (exi) {
            char *xsymbol;
            int slen;
            slen = strlen(lprefix);
            slen += strlen(lptr->defn.label);
            slen += strlen(lpostfix);
            slen++;             /* room for that null char */
            xsymbol = nasm_malloc(slen);
            snprintf(xsymbol, slen, "%s%s%s", lprefix, lptr->defn.label,
                     lpostfix);

            ofmt->symdef(xsymbol, segment, offset, exi,
                         special ? special : lptr->defn.special);
            ofmt->current_dfmt->debug_deflabel(xsymbol, segment, offset, exi,
                                               special ? special : lptr->defn.special);
            /**	nasm_free(xsymbol);  ! outobj.c stores the pointer; ouch!!! **/
        } else {
            if ((lptr->defn.is_global & (GLOBAL_BIT | EXTERN_BIT)) != EXTERN_BIT) {
                ofmt->symdef(lptr->defn.label, segment, offset, exi,
                             special ? special : lptr->defn.special);
                ofmt->current_dfmt->debug_deflabel(label, segment, offset, exi,
                                                   special ? special : lptr->defn.special);
            }
        }
    }   /* if (pass0 == 1) */
}
예제 #4
0
파일: labels.c 프로젝트: zoro0312/Liux
void redefine_label(char *label, int32_t segment, int64_t offset, char *special,
                    bool is_norm, bool isextrn)
{
    union label *lptr;
    int exi;

    /* This routine possibly ought to check for phase errors.  Most assemblers
     * check for phase errors at this point.  I don't know whether phase errors
     * are even possible, nor whether they are checked somewhere else
     */

    (void)special;              /* Don't warn that this parameter is unused */
    (void)is_norm;              /* Don't warn that this parameter is unused */
    (void)isextrn;              /* Don't warn that this parameter is unused */

#ifdef DEBUG
#if DEBUG < 3
    if (!strncmp(label, "debugdump", 9))
#endif
        nasm_error(ERR_DEBUG, "redefine_label (%s, %"PRIx32", %"PRIx64", %s, %d, %d)",
                   label, segment, offset, special, is_norm, isextrn);
#endif

    lptr = find_label(label, 1);
    if (!lptr)
        nasm_error(ERR_PANIC, "can't find label `%s' on pass two", label);

    if (!islocal(label)) {
        if (!islocalchar(*label) && lptr->defn.is_norm)
            prevlabel = lptr->defn.label;
    }

    if (lptr->defn.offset != offset)
        global_offset_changed++;

    lptr->defn.offset = offset;
    lptr->defn.segment = segment;

    if (pass0 == 1) {
        exi = !!(lptr->defn.is_global & GLOBAL_BIT);
        if (exi) {
            char *xsymbol;
            int slen;
            slen = strlen(lprefix);
            slen += strlen(lptr->defn.label);
            slen += strlen(lpostfix);
            slen++;             /* room for that null char */
            xsymbol = nasm_malloc(slen);
            snprintf(xsymbol, slen, "%s%s%s", lprefix, lptr->defn.label,
                     lpostfix);

            ofmt->symdef(xsymbol, segment, offset, exi,
                         special ? special : lptr->defn.special);
            ofmt->current_dfmt->debug_deflabel(xsymbol, segment, offset, exi,
                                               special ? special : lptr->defn.special);
            /**	nasm_free(xsymbol);  ! outobj.c stores the pointer; ouch!!! **/
        } else {
            if ((lptr->defn.is_global & (GLOBAL_BIT | EXTERN_BIT)) != EXTERN_BIT) {
                ofmt->symdef(lptr->defn.label, segment, offset, exi,
                             special ? special : lptr->defn.special);
                ofmt->current_dfmt->debug_deflabel(label, segment, offset, exi,
                                                   special ? special : lptr->defn.special);
            }
        }
    }   /* if (pass0 == 1) */
}