static bool dirFuncString( directive_t *dir, dir_table_enum parm ) //**************************************************************** { char *str, *ptr, *byte; dir_operand *dirop; int opnum; dirop = dir->operand_list; assert( dirop != NULL ); opnum = 0; while( dirop ) { assert( dirop->type == DIROP_STRING ); str = byte = MemAlloc( strlen( STRING_CONTENT( dirop ) ) + 1 ); for( ptr = STRING_CONTENT( dirop ); *ptr != '\0'; ptr++ ) { if( *ptr == ESCAPE_CHAR ) { ptr = getESCChar( byte, ptr ); } else { *byte = *ptr; } byte++; } if( parm == DT_STR_NULL ) { *byte++ = '\0'; } #ifdef _STANDALONE_ ObjEmitData( CurrentSection, str, byte - str, ( opnum == 0 ) ); #else ObjEmitData( str, byte - str, ( opnum == 0 ) ); #endif MemFree( str ); opnum++; dirop = dirop->next; } return( TRUE ); }
static bool dirFuncErr( directive_t *dir, dir_table_enum parm ) //************************************************************* { char *str; parm = parm; if( dirHasOperand( dir ) ) { assert( dir->num_operands == 1 ); assert( dir->operand_list->type == DIROP_LINE ); str = STRING_CONTENT( dir->operand_list ); if( *str ) { Error( GET_STRING, str ); } } return( FALSE ); // so that yyparse will terminate }
static bool dirFuncSetOption( directive_t *dir, dir_table_enum parm ) //******************************************************************* { char *str; /* unused parameters */ (void)parm; if( dirHasOperand( dir ) ) { assert( dir->num_operands == 1 ); assert( dir->operand_list->type == DIROP_LINE ); str = STRING_CONTENT( dir->operand_list ); if( optionString( str, "at" ) ) { _DirSet( AT ); } else if( optionString( str, "noat" ) ) { _DirUnSet( AT ); } else if( optionString( str, "macro" ) ) { _DirSet( MACRO ); } else if( optionString( str, "nomacro" ) ) { _DirUnSet( MACRO ); } else if( optionString( str, "reorder" ) ) { _DirSet( REORDER ); } else if( optionString( str, "noreorder" ) ) { _DirUnSet( REORDER ); } else if( optionString( str, "volatile" ) ) { // ignore this for now // _DirSet( VOLATILE ); } else if( optionString( str, "novolatile" ) ) { // ignore this for now // _DirUnSet( VOLATILE ); } else if( optionString( str, "move" ) ) { // ignore this for now // _DirSet( MOVE ); } else if( optionString( str, "nomove" ) ) { // ignore this for now // _DirUnSet( MOVE ); } else { Error( IMPROPER_SET_DIRECTIVE, str ); } } return( true ); }
static bool dirFuncUserSection( directive_t *dir, dir_table_enum parm ) //********************************************************************* { dir_operand *dirop; sym_handle sym; char *str, *s; owl_section_type type = OWL_SEC_ATTR_NONE; owl_section_type *ptype; owl_alignment align = 0; if( dir->num_operands > 2 ) { Error( DIROP_ERR_TOO_MANY ); return( TRUE ); } dirop = dir->operand_list; if( dirop->type != DIROP_SYMBOL ) { Error( IMPROPER_DIROP, 0 ); return( TRUE ); } sym = SYMBOL_HANDLE( dirop ); if( dir->num_operands == 2 ) { dirop = dirop->next; if( dirop->type != DIROP_STRING ) { Error( IMPROPER_DIROP, 1 ); return( TRUE ); } str = STRING_CONTENT( dirop ); } else { str = NULL; } if( str ) { s = str; while( *s ) { switch( *s ) { case 'c': type |= OWL_SEC_ATTR_CODE; break; case 'd': type |= OWL_SEC_ATTR_DATA; break; case 'u': type |= OWL_SEC_ATTR_BSS; break; case 'i': type |= OWL_SEC_ATTR_INFO; break; case 'n': type |= OWL_SEC_ATTR_DISCARDABLE; break; case 'R': type |= OWL_SEC_ATTR_REMOVE; break; case 'r': type |= OWL_SEC_ATTR_PERM_READ; break; case 'w': type |= OWL_SEC_ATTR_PERM_WRITE; break; case 'x': type |= OWL_SEC_ATTR_PERM_EXEC; break; case 's': type |= OWL_SEC_ATTR_PERM_SHARE; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': align = 1 << (*s - '0'); break; default: Error( INVALID_SECT_ATTR, *s ); break; } s++; } ptype = &type; } else { // default is just read & write ptype = NULL; } if( parm == DT_USERSEC_NEW ) { SectionNew( SymName( sym ), ptype, align ); } else { SectionSwitch( SymName( sym ), ptype, align ); } return( TRUE ); }