예제 #1
0
static symbol *DoSymOp( sym_flags op, char *symname, size_t length )
/******************************************************************/
{
    unsigned    hash;
    symbol      *sym;
    size_t      searchlen;
#ifdef _INT_DEBUG
    char        *symname_dbg;

    symname_dbg = alloca( length + 1 );
    memcpy( symname_dbg, symname, length );
    symname_dbg[ length ] = '\0';
#endif
    DEBUG(( DBG_OLD, "SymOp( %d, %s, %d )", op, symname_dbg, length ));
    if( NameLen != 0 && NameLen < length ) {
        searchlen = NameLen;
    } else {
        searchlen = length;
    }
    if( op & ST_STATIC ) {
        hash = StaticHashFn( symname, searchlen );
        /* If symbol isn't unique, don't look for duplicates. */
        if( (op & (ST_CREATE | ST_STATIC | ST_NONUNIQUE)) ==
                  (ST_CREATE | ST_STATIC | ST_NONUNIQUE) )
            sym = NULL;
        else
            sym = StaticSearchSym( symname, hash, searchlen );
    } else {
        hash = GlobalHashFn( symname, searchlen );
        sym = GlobalSearchSym( symname, hash, searchlen );
    }
    DEBUG(( DBG_OLD, "- hash %d", hash ));
    if( sym != NULL ) {
        DEBUG(( DBG_OLD, "found symbol %s", symname_dbg ));
        DEBUG(( DBG_OLD, " - handle = %h", sym ));
        return( sym );
    }
    if( !(op & ST_FIND) ) {
        sym = AddSym();
        sym->name = AddSymbolStringTable( &PermStrings, symname, length );
        sym->namelen_cmp = searchlen;

        if( op & ST_STATIC ) {
            sym->info |= SYM_STATIC;
            sym->hash = StaticSymPtrs[hash];
            StaticSymPtrs[hash] = sym;
        } else {
            sym->hash = GlobalSymPtrs[hash];
            GlobalSymPtrs[hash] = sym;
        }
        DEBUG((DBG_OLD, "added symbol %s", symname_dbg ));
    }
    return( sym );
}
예제 #2
0
파일: lsymtab.c 프로젝트: JWasm/JWlink
static symbol *DoSymOp( sym_flags op, char *symname, unsigned length )
/********************************************************************/
{
    unsigned    hash;
    symbol      *sym;
    unsigned    searchlen;
#ifdef _INT_DEBUG
    char        *symname_dbg;

    symname_dbg = alloca( length + 1 );
    memcpy( symname_dbg, symname, length );
    symname_dbg[ length ] = '\0';
#endif
    if( NameLen != 0 && NameLen < length ) {
        searchlen = NameLen;
    } else {
        searchlen = length;
    }
    if( op & ST_STATIC ) {
        hash = StaticHashFn( symname, searchlen );
        /* jwlink: allow duplicate static symbols */
        //sym = StaticSearchSym( symname, hash, searchlen );
        if ( ( op & ( ST_CREATE|ST_STATIC|ST_DUPLICATE ) ) == ( ST_CREATE|ST_STATIC|ST_DUPLICATE) )
            sym = NULL;
        else
            sym = StaticSearchSym( symname, hash, searchlen );
    } else {
        hash = GlobalHashFn( symname, searchlen );
        sym = GlobalSearchSym( symname, hash, searchlen );
    }
    DEBUG(( DBG_OLD, "SymOp( %d, %s, %d ) - hash %d - handle = %h", op, symname_dbg, length, hash, sym ));
    if( sym != NULL ) {
        //DEBUG(( DBG_OLD, "found symbol %s", symname_dbg ));
        //DEBUG(( DBG_OLD, " - handle = %h", sym ));
        return( sym );
    }
    if( !(op & ST_FIND) ) {
        sym = AddSym();
        sym->name = AddSymbolStringTable( &PermStrings, symname, length );
        sym->namelen_cmp = searchlen;

        if( op & ST_STATIC ) {
            sym->info |= SYM_STATIC;
            sym->hash = StaticSymPtrs[hash];
            StaticSymPtrs[hash] = sym;
        } else {
            sym->hash = GlobalSymPtrs[hash];
            GlobalSymPtrs[hash] = sym;
        }
        DEBUG((DBG_OLD, "DoSymOp: added symbol %s hdl=%h info=%h", symname_dbg, sym, sym->info ));
    }
    return( sym );
}