Changeset 1517


Ignore:
Timestamp:
12/30/11 13:39:02 (17 months ago)
Author:
tsv
Message:
  • Improved startup stability (run module_menu on first menu popup instead of runing in startup sequence)
  • Added stoplist (unsafe symbols) to elf2flt. give no chance to make unobvious mistake
Location:
branches/reyalp-flt
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/reyalp-flt/core/gui.c

    r1516 r1517  
    152152static void gui_show_build_info(int arg); 
    153153static void gui_show_memory_info(int arg); 
    154 static void     gui_modules_menu_load(); 
     154void    gui_modules_menu_load(); 
    155155 
    156156#ifdef OPT_DEBUGGING 
     
    16151615    gui_splash = (conf.splash_show)?SPLASH_TIME:0; 
    16161616 
    1617         gui_modules_menu_load(); 
    1618     user_menu_restore(); 
    16191617    gui_lang_init(); 
    16201618    draw_init(); 
  • branches/reyalp-flt/core/gui_menu.c

    r1514 r1517  
    4747//------------------------------------------------------------------- 
    4848void gui_menu_init(CMenu *menu_ptr) { 
     49 
     50    static char first_call=1; 
     51 
    4952    if (menu_ptr) { 
     53                if ( first_call ) { 
     54                        extern void gui_modules_menu_load(); 
     55                        extern void user_menu_restore(); 
     56 
     57                        gui_modules_menu_load(); 
     58                user_menu_restore(); 
     59                        first_call=0; 
     60                } 
     61 
    5062        if (conf.menu_select_first_entry) 
    5163            gui_menu_set_curr_menu(menu_ptr, 0, 0); 
  • branches/reyalp-flt/core/modules/Makefile

    r1512 r1517  
    4343#       arm-elf-objdump.exe -d -r -x $< >$<.dumpobj 
    4444#       $(topdir)/tools/elf2flt/elf2flt$(EXE) $< $@ -e -f -h -r -s -iexportlist.txt >$@.dump 
    45         $(topdir)/tools/elf2flt/elf2flt$(EXE) $< $@ -iexportlist.txt > $(DEVNULL) 
     45        $(topdir)/tools/elf2flt/elf2flt$(EXE) $< $@ -iexportlist.txt -!$(topdir)/tools/elf2flt/stoplist.txt > $(DEVNULL) 
    4646 
    4747calend.elf: simple_module.o ../gui_calendar.o 
  • branches/reyalp-flt/tools/elf2flt/elfflt.c

    r1510 r1517  
    5353 
    5454char* flag_sym_display=0;  // buffer of flags. [symidx]=0 not_showed_yet, 1 already_shown 
     55int flag_unsafe_sym=0;      // =1 if one of imported symbol is from stoplist 
    5556 
    5657/*---------------------------------------------------------------------------*/ 
     
    198199                  continue; 
    199200      } 
     201      if ( stoplist_check(name) ) 
     202              { flag_unsafe_sym=1; } 
    200203 
    201204      ret = apply_import( base_sect, &rela, importidx, &s, relidx); 
     
    627630  add_div0_arm(); 
    628631 
     632  flag_unsafe_sym = 0; 
     633 
    629634  // Do relocations 
    630635  ret = relocate_section( &text); 
     
    637642  if(ret != ELFFLT_OK) 
    638643      return ret; 
     644 
     645  if ( flag_unsafe_sym ) 
     646      return ELFFLT_UNSAFE_SYMBOL; 
    639647 
    640648  flat->import_start = flat->reloc_start+flat_reloc_count*sizeof(reloc_record_t); 
  • branches/reyalp-flt/tools/elf2flt/elfflt.h

    r1510 r1517  
    1818#define ELFFLT_INPUT_ERROR         10 
    1919#define ELFFLT_OUTPUT_ERROR        11 
     20#define ELFFLT_UNSAFE_SYMBOL       12 
    2021 
    2122 
  • branches/reyalp-flt/tools/elf2flt/main.c

    r1510 r1517  
    2525        printf("elfflt.exe filename.elf filename.flt [-vefrhsS] [-iIMPORTFILE.TXT]\n"); 
    2626                printf("  -iPATH/TO/exportlist.txt for list of imported symbols\n"); 
     27                printf("  -!PATH/TO/stoplist.txt for list of unsafe symbols\n"); 
    2728                printf("  -e dump elf\n  -S show elf sections\n  -f dump flat\n  -r show relocations\n  -h show flat headers\n  -s dump elf symbols\n  -v verbose"); 
    2829        return 1; 
     
    3334 
    3435        char* filename_import =0; 
     36        char* filename_stoplist =0; 
    3537 
    3638        int i; 
     
    4850                  case 'v': FLAG_VERBOSE = 1; break; 
    4951                  case 'i': filename_import = argv[i]+2; break;  
     52                  case '!': filename_stoplist = argv[i]+2; break; 
    5053                } 
    5154    } 
     
    6265 
    6366        load_import(filename_import); 
     67        load_stoplist(filename_stoplist); 
    6468       
    6569    int err = elfloader_load(filename_elf, filename_flt); 
  • branches/reyalp-flt/tools/elf2flt/myio.c

    r1510 r1517  
    199199} 
    200200 
     201 
     202//========================================== 
     203 
     204struct StopListRecord { 
     205        char* symbol; 
     206        char* warning; 
     207        void* next;      
     208}; 
     209 
     210 
     211char *stoplist_buf=0; 
     212struct StopListRecord* stoplisthead=0; 
     213 
     214 
     215int load_stoplist(char* stopfile) 
     216{ 
     217        if ( !stopfile ) 
     218          return 0; 
     219 
     220        int fd=open(stopfile, O_RDONLY|O_BINARY, 0777); 
     221 
     222    if ( fd <=0 ) { 
     223                PRINTERR(stderr,"No stoplist file '%s' found\n",stopfile); 
     224                return 0; 
     225        } 
     226    int stoplistfilesize = lseek(fd,0,SEEK_END); 
     227        if ( FLAG_VERBOSE ) 
     228        printf("Stoplist file '%s' size=%d\n",stopfile, stoplistfilesize); 
     229 
     230    stoplist_buf=malloc(stoplistfilesize+1);     
     231    if (!stoplist_buf) return 0; 
     232 
     233    int now=0, loaded =0;  
     234        if (lseek(fd, 0, SEEK_SET) != 0) return 0; 
     235        do 
     236        {  
     237      now = read(fd, stoplist_buf+loaded, stoplistfilesize-loaded); 
     238      loaded+=now; 
     239    } while (loaded<stoplistfilesize && now); 
     240 
     241        stoplist_buf[loaded]=0; 
     242        close(fd); 
     243        
     244    if ( loaded != stoplistfilesize ) 
     245      return -loaded; 
     246 
     247    // Parse 
     248    struct StopListRecord record; 
     249        char* sym=0, *finsym=0; 
     250    char* cur=stoplist_buf; 
     251 
     252    for ( ; cur<(stoplist_buf+stoplistfilesize); ) { 
     253                for(;*cur==' '; cur++); // skip spaces 
     254 
     255                sym=cur; 
     256                for(;*cur && *cur!=9 && *cur!=' ' && *cur!=0x0a; cur++); 
     257                if ( cur==sym ) { 
     258                        for(;*cur && *cur!=10; cur++); 
     259                        if ( *cur==10) {cur++;} 
     260                        continue; 
     261                } 
     262 
     263                record.symbol = sym;     
     264                record.warning = "Error: unsafe symbol used. Please check stoplist"; 
     265                finsym=cur; 
     266                for(;*cur && *cur!=9 && *cur!=0x0a; cur++);     // find \t 
     267 
     268                if ( *cur==0 ) break; 
     269                if ( *cur==9 ) { 
     270                        cur++; 
     271                        record.warning=cur; 
     272                } 
     273                 
     274                for(;*cur && *cur!=10; cur++);          // find eol 
     275                if ( *cur==0x0a && cur>stoplist_buf && *(cur-1)==0x0d) 
     276                        *(cur-1)=0; 
     277 
     278                if (cur==record.warning) 
     279                        record.warning = "Error: unsafe symbol used. Please check stoplist"; 
     280 
     281                record.next=stoplisthead; 
     282                stoplisthead = malloc (sizeof(struct StopListRecord)); 
     283                memcpy( stoplisthead, &record, sizeof(struct StopListRecord)); 
     284 
     285                if ( *cur!=0 ) { *cur=0; cur++;} 
     286                *finsym = 0; 
     287 
     288                if ( FLAG_VERBOSE ) 
     289                        printf("Stop record: %s => %s\n",record.symbol, record.warning); 
     290        } 
     291 
     292        return loaded; 
     293} 
     294 
     295//return: 1 - found in stoplist, 0 - not found 
     296int stoplist_check(char *sym) 
     297{ 
     298        struct StopListRecord *cur; 
     299   
     300        for ( cur = stoplisthead; cur; cur = cur->next ) { 
     301                if ( !cur->symbol ) 
     302                        continue; 
     303                if ( !strcmp( sym, cur->symbol) ) { 
     304                        PRINTERR(stderr,"%s\n",cur->warning); 
     305                        cur->symbol = 0;  // mark that this symbol is already warned 
     306                        return 1; 
     307                } 
     308        } 
     309        return 0; 
     310} 
     311 
     312 
    201313//========================================== 
    202314void raise_error() 
  • branches/reyalp-flt/tools/elf2flt/myio.h

    r1510 r1517  
    2121char* get_import_symbol( unsigned symidx ); 
    2222 
     23int load_stoplist(char* importfile); 
     24int stoplist_check(char *sym);  //1 - found in stoplist, 0- not found 
     25 
    2326extern int FLAG_DUMP_SOURCE; 
    2427extern int FLAG_DUMP_SYMBOLS; 
Note: See TracChangeset for help on using the changeset viewer.