Annotation of researchv9/jerq/sgs/strip/checkflags.c, revision 1.1.1.1

1.1       root        1: /* UNIX HEADER */
                      2: #include       <stdio.h>
                      3: 
                      4: /* COMMON SGS HEADERS */
                      5: #include       "filehdr.h"
                      6: #include       "ldfcn.h"
                      7: 
                      8: 
                      9:     /*  checkflags(filename, &filehead)
                     10:      *
                     11:      *  checks and sets object file header flags appropriately
                     12:      *
                     13:      *  checkflags returns SUCCESS or FAILURE
                     14:      *
                     15:      *  checkflags will FAIL (and strip won't strip) in the following cases:
                     16:      *  if there is no symbol table (strip announces the fact if lflag, xflag
                     17:      *  or bflag imply that symbols were expected)
                     18:      *  if lflag, xflag or bflag is ON and there are no local symbols 
                     19:      *  if lflag is OFF and there are relocation entries 
                     20:      *
                     21:      *  the file flags in the file header are set to reflect the new state of
                     22:      *  of the file:
                     23:      *  if xflag, bflag and lflag are all OFF there will be no symbols nor any
                     24:      *  line numbers in the file
                     25:      *  if xflag is ON then there will be no local symbols nor any line numbers
                     26:      *  if bflag is ON then there will be no local symbols except .bb, .eb, .bf
                     27:      *  and .ef
                     28:      *  if lflag is ON then there will be no line numbers
                     29:      */
                     30: 
                     31: 
                     32: int
                     33: checkflags(filename, filehead)
                     34: 
                     35: char   *filename;
                     36: FILHDR *filehead;
                     37: 
                     38: {
                     39:     /* STRIP FUNCTION CALLED */
                     40:     extern             error( );
                     41: 
                     42:     /* EXTERNAL VARIABLES USED */
                     43:     extern LDFILE      *ldptr;
                     44:     extern int         lflag,
                     45:                        xflag,
                     46:                        bflag,
                     47:                        sflag,
                     48:                        rflag;
                     49:        extern int      fflag;
                     50: 
                     51:     /* LOCAL VARIABLE */
                     52:     unsigned short     filflags;
                     53: 
                     54:     if (filehead->f_nsyms == 0L) {
                     55:        if (lflag || xflag || bflag || rflag || sflag || fflag ) {
                     56:            error(filename, "no symbol table", 1);
                     57:           onintr();
                     58:        }
                     59:        return(FAILURE);
                     60: 
                     61:     } else if (!(lflag || xflag || bflag || rflag || sflag || fflag)) {
                     62:        filehead->f_nsyms = 0L;
                     63:     }
                     64: 
                     65:     filflags = filehead->f_flags;
                     66: 
                     67:     if (sflag && (filflags & F_LSYMS) != 0)
                     68:     {
                     69:            error(filename, "no local symbols", 1);
                     70:            return(FAILURE);
                     71:     }
                     72: 
                     73:        if (((!rflag) && (!fflag) && (!lflag)) && (filflags & F_RELFLG) == 0) {
                     74:            error(filename, "relocation entries; cannot strip", 1);
                     75:            return(FAILURE);
                     76:        }
                     77: 
                     78: #if !UNIX
                     79:        if (fflag && !(filflags & F_EXEC)) {
                     80:                error( filename, "not executable, cannot strip", 1);
                     81:                return( FAILURE );
                     82:        }
                     83: #endif
                     84: 
                     85:     return(SUCCESS);
                     86: }
                     87: /*
                     88:  *     @(#)checkflags.c        1.6 11/4/83;
                     89:  */

unix.superglobalmegacorp.com

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