/[gcl]/gcl/o/sfaslpecoff.c
ViewVC logotype

Diff of /gcl/o/sfaslpecoff.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mjthomas, Sun Aug 29 02:46:03 2004 UTC revision 1.3 by mjthomas, Sun Aug 29 03:35:18 2004 UTC
# Line 13  Line 13 
13     via #include "../c/sfasl.c\n"     via #include "../c/sfasl.c\n"
14     */     */
15    
   
 /* for testing in standalone manner define STAND  
    You may then compile this file cc -g -DSTAND -DDEBUG -I../hn  
    a.out /tmp/foo.o /public/gcl/unixport/saved_kcl /public/gcl/unixport/  
    will write a /tmp/sfasltest file  
    which you can use comp to compare with one produced by ld.  
    */  
16  #if 0  #if 0
17  #define DEBUG  #define DEBUG
18  #endif  #endif
19    
20  #define IN_SFASL  #define IN_SFASL
21    
 /*  #ifdef STAND */  
 /*  #include "config.h" */  
 /*  #include "gclincl.h" */  
 /*  #define OUR_ALLOCA alloca */  
 /*  #include <stdio.h> */  
 /*  #include "mdefs.h" */  
   
 /*  #else */  
22  #include "gclincl.h"  #include "gclincl.h"
23  #include "include.h"  #include "include.h"
24  #undef S_DATA  #undef S_DATA
 /*  #endif */  
   
 #ifdef SEPARATE_SFASL_FILE  
 #include SEPARATE_SFASL_FILE  
 #else  
25    
26  #include "ext_sym.h"  #include "ext_sym.h"
27  struct node * find_sym();  struct node * find_sym();
# Line 153  void describe_sym1 ( int n, int aux_to_g Line 133  void describe_sym1 ( int n, int aux_to_g
133  #  define describe_sym(a,b)  #  define describe_sym(a,b)
134  #endif /* DEBUG */  #endif /* DEBUG */
135    
   
 #ifdef STAND  
 #include "rel_stand.c"  
 #endif  
   
136  /* begin reloc_file */  /* begin reloc_file */
137  #include RELOC_FILE  #include RELOC_FILE
138    
# Line 224  int fasload ( object faslfile ) Line 199  int fasload ( object faslfile )
199      int init_address=0;      int init_address=0;
200      int aux_to_go = 0;      int aux_to_go = 0;
201      size_t sections_read = 0;      size_t sections_read = 0;
       
 #ifndef STAND    
202      object *old_vs_base = vs_base;      object *old_vs_base = vs_base;
203      object *old_vs_top = vs_top;      object *old_vs_top = vs_top;
 #endif  
204    
205      /* Zero out the COFF section header storage space */          /* Zero out the COFF section header storage space */    
206      memset ( section, 0, COFF_SECTIONS * sizeof ( struct scnhdr ) );      memset ( section, 0, COFF_SECTIONS * sizeof ( struct scnhdr ) );
# Line 236  int fasload ( object faslfile ) Line 208  int fasload ( object faslfile )
208      sfaslp = &sfasl_info_buf;      sfaslp = &sfasl_info_buf;
209    
210      extra_bss=0;      extra_bss=0;
 #ifdef STAND  
     strcpy(filename,faslfile);  
     fp=fopen(filename,"r");  
 #else  
211      coerce_to_filename(faslfile, filename);      coerce_to_filename(faslfile, filename);
212      faslfile = open_stream(faslfile, smm_input, Cnil, sKerror);      faslfile = open_stream(faslfile, smm_input, Cnil, sKerror);
213      vs_push(faslfile);      vs_push(faslfile);
214      fp = faslfile->sm.sm_fp;      fp = faslfile->sm.sm_fp;
 #endif    
215    
216      /* Read the object file header */      /* Read the object file header */
217      HEADER_SEEK(fp);      HEADER_SEEK(fp);
# Line 363  int fasload ( object faslfile ) Line 330  int fasload ( object faslfile )
330                                      bsssize );                                      bsssize );
331                    
332          /* allocate some memory */          /* allocate some memory */
 #ifndef STAND    
333          {          {
334              BEGIN_NO_INTERRUPT;              BEGIN_NO_INTERRUPT;
335              memory = alloc_object ( t_cfdata );              memory = alloc_object ( t_cfdata );
# Line 379  int fasload ( object faslfile ) Line 345  int fasload ( object faslfile )
345              sfaslp->s_start_bss   = sfaslp->s_start_rdata + rdatasize;              sfaslp->s_start_bss   = sfaslp->s_start_rdata + rdatasize;
346              END_NO_INTERRUPT;              END_NO_INTERRUPT;
347          }          }
 #else  
         /* What does this mean? */  
 #  ifdef SILLY          
         the_start = start_address  
             = malloc ( datasize + textsize + bsssize + stabsize + stabstrsize + rdatasize + extra_bss + 0x80000 );  
         the_start = start_address = (char *) ( 0x1000 * ( ( ( (int) the_start + 0x70000) + 0x1000) / 0x1000 ) );  
 #  else  /* SILLY */  
         the_start = start_address  
             = malloc ( datasize + textsize + bsssize + stabsize + stabstrsize + rdatasize + extra_bss );  
 #  endif /* SILLY */        
         sfaslp->s_start_data  = start_address + textsize;  
         sfaslp->s_start_rdata = sfaslp->s_start_data + datasize + stabsize + stabstrsize;  
         sfaslp->s_start_bss   = sfaslp->s_start_rdata + rdatasize;  
 #endif  
348          dprintf(" Code size %d, ", datasize+rdatasize+textsize+bsssize + extra_bss);          dprintf(" Code size %d, ", datasize+rdatasize+textsize+bsssize + extra_bss);
349          if ( fseek ( fp, N_TXTOFF(fileheader), 0) < 0 ) {          if ( fseek ( fp, N_TXTOFF(fileheader), 0) < 0 ) {
350              FEerror("file seek error",0);              FEerror("file seek error",0);
# Line 409  int fasload ( object faslfile ) Line 361  int fasload ( object faslfile )
361                    memory->cfd.cfd_start,                    memory->cfd.cfd_start,
362                    memory->cfd.cfd_start +  memory->cfd.cfd_size );                    memory->cfd.cfd_start +  memory->cfd.cfd_size );
363  #endif          #endif        
         /* record which symbols are used */  
           
 #ifdef SYM_USED  
         {  
             int j=0;  
             for(j=1; j< BSS_NSCN ; j++) {  
                 dprintf(" relocating section %d \n",j);  
                 if (section[j].s_nreloc) fseek(fp,section[j].s_relptr,0);  
                 for(i=0; i < section[j].s_nreloc; i++) {  
                     struct syment *sym;  
                     fread(&relocation_info, RELSZ, 1, fp);  
                     sym = & symbol_table[relocation_info.r_symndx];  
                     if (TC_SYMBOL_P(sym)) {  
                         SYM_USED(sym) = 1;  
                     }  
                 }  
             }  
         }  
 #endif  
364          /* this looks up symbols in c.ptable and also adds new externals to          /* this looks up symbols in c.ptable and also adds new externals to
365             that c.table */             that c.table */
366          relocate_symbols(NSYMS(fileheader));            relocate_symbols(NSYMS(fileheader));  
# Line 504  int fasload ( object faslfile ) Line 437  int fasload ( object faslfile )
437          }          }
438          close_stream(faslfile);          close_stream(faslfile);
439    
 #ifndef STAND  
440          ALLOCA_FREE(my_string_table);          ALLOCA_FREE(my_string_table);
441          ALLOCA_FREE(symbol_table);          ALLOCA_FREE(symbol_table);
442          dprintf ( "About to call_init %x \n", init_address );          dprintf ( "About to call_init %x \n", init_address );
# Line 519  int fasload ( object faslfile ) Line 451  int fasload ( object faslfile )
451              printf("start address -T %x ", memory->cfd.cfd_start);              printf("start address -T %x ", memory->cfd.cfd_start);
452          }          }
453          return ( memory->cfd.cfd_size );          return ( memory->cfd.cfd_size );
 #endif  
         printf("\n(start %x)\n",start_address);  
454      }      }
455  }  }
456    
# Line 676  void print_name ( struct syment *p ) Line 606  void print_name ( struct syment *p )
606  }  }
607  #endif  #endif
608    
 #endif /* SEPARATE_SFASL_FILE */  

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26