Annotation of researchv9/cmd/strip/prtsym.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include <a.out.h>
        !             3: #include <time.h>
        !             4: #define        DESCNAMES
        !             5: #define        DESCSYMBS
        !             6: #include "stab.h"
        !             7: 
        !             8: int strdebug;
        !             9: 
        !            10: static char *typnam[128];
        !            11: static int init;
        !            12: 
        !            13: prtsym(stream,sym)
        !            14: FILE *stream; register struct nlist *sym;
        !            15: {
        !            16:        int jtype, jext; char tqual[8]; struct tm *ctm, *localtime();
        !            17:        register i; register unsigned w;
        !            18:        if (!init) {
        !            19:                typnam[N_UNDF/2] = "UNDF";
        !            20:                typnam[N_ABS/2] = "ABS";
        !            21:                typnam[N_TEXT/2] = "TEXT";
        !            22:                typnam[N_DATA/2] = "DATA";
        !            23:                typnam[N_BSS/2] = "BSS";
        !            24:        
        !            25:                typnam[N_SO/2] = "SO";
        !            26:                typnam[N_ESO/2] = "ESO";
        !            27:                typnam[N_SOL/2] = "SOL";
        !            28:                typnam[N_SLINE/2] = "SLINE";
        !            29:                typnam[N_BFUN/2] = "BFUN";
        !            30:                typnam[N_ENTRY/2] = "ENTRY";
        !            31:                typnam[N_RFUN/2] = "RFUN";
        !            32:                typnam[N_LBRAC/2] = "LBRAC";
        !            33:                typnam[N_RBRAC/2] = "RBRAC";
        !            34:                typnam[N_EFUN/2] = "EFUN";
        !            35:                typnam[N_STSYM/2] = "STSYM";
        !            36:                typnam[N_LCSYM/2] = "LCSYM";
        !            37:                typnam[N_ECOML/2] = "ECOML";
        !            38:                typnam[N_GSYM/2] = "GSYM";
        !            39:                typnam[N_STFUN/2] = "STFUN";
        !            40:                typnam[N_RSYM/2] = "RSYM";
        !            41:                typnam[N_LSYM/2] = "LSYM";
        !            42:                typnam[N_PSYM/2] = "PSYM";
        !            43:                typnam[N_BSTR/2] = "BSTR";
        !            44:                typnam[N_ESTR/2] = "ESTR";
        !            45:                typnam[N_SSYM/2] = "SSYM";
        !            46:                typnam[N_SFLD/2] = "SFLD";
        !            47:                typnam[N_BCOMM/2] = "BCOMM";
        !            48:                typnam[N_ECOMM/2] = "ECOMM";
        !            49:                typnam[N_FNAME/2] = "FNAME";
        !            50:                typnam[N_LENG/2] = "LENG";
        !            51:                typnam[N_NARGS/2] = "NARGS";
        !            52:                typnam[N_TYID/2] = "TYID";
        !            53:                typnam[N_DIM/2] = "DIM";
        !            54:                typnam[N_VER/2] = "VER";
        !            55:                init++;
        !            56:        }
        !            57:        jtype = sym->n_type/2;
        !            58:        jext  = sym->n_type&N_EXT;
        !            59:        fputs(sym->n_un.n_name, stream); putc('\t', stream);
        !            60:        if (strlen(sym->n_un.n_name) < 8) putc('\t', stream);
        !            61:        fputs(typnam[jtype], stream);
        !            62:        if (jext) putc('\'', stream); putc('\t', stream);
        !            63: 
        !            64:        switch (sym->n_type&(~N_EXT)) {
        !            65:        case N_UNDF:    /* undefined */
        !            66:        case N_ABS:     /* absolute */
        !            67:        case N_TEXT:    /* text */
        !            68:        case N_DATA:    /* data */
        !            69:        case N_BSS:     /* bss */
        !            70:        
        !            71:        case N_SO:      /* source file name: name,,address */
        !            72:        case N_SOL:     /* #line source filename: name,,address */
        !            73:        case N_SLINE:   /* src line: ,linenumber,address */
        !            74:        case N_RFUN:    /* return from function:  ,,0,linenumber,address */
        !            75:        case N_ESO:     /* end source file: name,,0,0,address */
        !            76:        case N_ENTRY:   /* alternate entry: name,linenumber,address */
        !            77:        case N_BFUN:    /* procedure: name,lineno,address */
        !            78:        case N_EFUN:    /* end of function: name,lineno,address */
        !            79:        case N_LBRAC:   /* left bracket: ,nesting level,address */
        !            80:        case N_RBRAC:   /* right bracket: ,nesting level,address */
        !            81:        case N_ECOML:   /* end common (local name): ,,address */
        !            82:        case N_BCOMM:   /* begin common: name,, */
        !            83:        case N_ECOMM:   /* end common: name,, */
        !            84:        case N_FNAME:   /* procedure name (f77 kludge): name,,0 */
        !            85:        case N_NARGS:   /* number of args in the function call */
        !            86:                fprintf(stream,"\t%5d\t%08x",
        !            87:                        sym->n_desc,sym->n_value);
        !            88:                break;
        !            89: 
        !            90:        case N_LENG:    /* additional entry with length: ,,length */
        !            91:        case N_TYID:    /* struct, union, or enum name */
        !            92:        case N_DIM:     /* dimension for arrays, etc */
        !            93:                fprintf(stream,"\t%5d\t%8d",
        !            94:                        sym->n_desc,sym->n_value);
        !            95:                break;
        !            96:        
        !            97:        case N_BSTR:    /* begin structure: name,, */
        !            98:        case N_ESTR:    /* end structure: name,, */
        !            99:        case N_STSYM:   /* static symbol: name,type,address */
        !           100:        case N_LCSYM:   /* .lcomm symbol: name,type,address */
        !           101:        case N_GSYM:    /* global sym: name,type,0 */
        !           102:        case N_STFUN:   /* static function: name,type,0 */
        !           103:        case N_RSYM:    /* register sym: name,register,offset */
        !           104:        case N_LSYM:    /* local sym: name,type,offset */
        !           105:        case N_PSYM:    /* parameter: name,type,offset */
        !           106:        case N_SSYM:    /* structure elt: name,type,struct_offset */
        !           107:                i = 0; w = sym->n_desc >> (BTSHIFT-TSHIFT);
        !           108:                while (tqual[i++] = qualchars[(w >>= TSHIFT)&MTMASK]);
        !           109:                while (i++ < 7) putc(' ', stream);
        !           110:                printf("%s%s\t%08x",
        !           111:                        tqual,basenames[BTYPE(sym->n_desc)],
        !           112:                        sym->n_value);
        !           113:                break;
        !           114:        
        !           115:        case N_SFLD:    /* structure field: name,,0,type,struct_offset */
        !           116:                printf(" %s<%d>\t%08x",
        !           117:                        basenames[BTYPE(sym->n_desc)], sym->n_desc >> BTSHIFT,
        !           118:                        sym->n_value);
        !           119:                break;
        !           120:        
        !           121:        case N_VER:     /* symbol table version */
        !           122:                ctm = localtime(&sym->n_value);
        !           123:                fprintf(stream,"%2d.%02d.%02x  %2d.%02d.%02d.%02d:%02d",
        !           124:                        ((sym->n_desc>>12)&0x0f)+80,
        !           125:                        (sym->n_desc>>8)&0x0f, sym->n_desc&0xff,
        !           126:                        ctm->tm_year, ctm->tm_mon+1, ctm->tm_mday,
        !           127:                        ctm->tm_hour,ctm->tm_min);
        !           128:                break;
        !           129:        
        !           130:        default:
        !           131:                fprintf(stream,"%02x %02x\t%04x\t%08x",
        !           132:                        sym->n_type,sym->n_other,sym->n_desc,sym->n_value);
        !           133:                break;
        !           134:        }
        !           135:        if (strdebug && sym->n_un.n_name)
        !           136:                fprintf(stream,"\t%8x",sym->n_un.n_name);
        !           137:        putc('\n', stream);
        !           138: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.