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

Diff of /gcl/o/sfasl.c

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

revision 1.7 by mjthomas, Mon Sep 23 14:02:10 2002 UTC revision 1.8 by mjthomas, Mon Sep 23 14:47:37 2002 UTC
# Line 101  struct sfasl_info *sfaslp; Line 101  struct sfasl_info *sfaslp;
101  #include RELOC_FILE  #include RELOC_FILE
102    
103  /* end reloc_file */  /* end reloc_file */
104    int get_extra_bss ( struct syment *sym_table, int length, int start, int *ptr, int bsssize);
105    void relocate_symbols ( unsigned int length );
106    void set_symbol_address ( struct syment *sym, char *string );
107    
108  int  int
109  fasload(faslfile)  fasload(faslfile)
# Line 378  ADJUST_RELOC_START(j) Line 381  ADJUST_RELOC_START(j)
381    
382  }  }
383    
384                      int get_extra_bss(sym_table,length,start,ptr,bsssize)
385  get_extra_bss(sym_table,length,start,ptr,bsssize)       int length,bsssize;
386  int length,bsssize;       struct syment *sym_table;
387  struct syment *sym_table;       int *ptr;   /* store init address offset here */
388  int *ptr;   /* store init address offset here */  {
389  {int result = start;    int result = start;
390   int next_bss =  start - bsssize;  
391   struct syment *end,*sym;  #ifdef AIX3
392   char tem[SYMNMLEN +1];    int next_bss =  start - bsssize;
393   end =sym_table + length;  #endif
394   for(sym=sym_table; sym < end; sym++)  
395     {    struct syment *end,*sym;
396    
397    #ifdef BSD
398      char tem[SYMNMLEN +1];
399    #endif
400    
401      end =sym_table + length;
402      for(sym=sym_table; sym < end; sym++)
403        {
404            
405  #ifdef FIND_INIT  #ifdef FIND_INIT
406  FIND_INIT        FIND_INIT
407  #endif  #endif
408    
409  #ifdef AIX3  #ifdef AIX3
410   /* we later go through the relocation entries making this 1          /* we later go through the relocation entries making this 1
411      for symbols used */             for symbols used */
412  #ifdef SYM_USED  #ifdef SYM_USED
413   if(TC_SYMBOL_P(sym))          if(TC_SYMBOL_P(sym))
414     {SYM_USED(sym) = 0;}            {SYM_USED(sym) = 0;}
415  #endif  #endif
416    
417   /* fix up the external refer to _ptrgl to be local ref */        /* fix up the external refer to _ptrgl to be local ref */
418   if (sym->n_scnum == 0 &&        if (sym->n_scnum == 0 &&
419       strcmp(sym->n_name,"_ptrgl")==0)            strcmp(sym->n_name,"_ptrgl")==0)
420     {struct syment* s =          {struct syment* s =
421        get_symbol("._ptrgl",TEXT_NSCN,sym_table,length);             get_symbol("._ptrgl",TEXT_NSCN,sym_table,length);
422      if (s ==0) FEerror("bad glue",0,0);          if (s ==0) FEerror("bad glue",0,0);
423      sym->n_value = next_bss ;          sym->n_value = next_bss ;
424      ptrgl_offset = next_bss;          ptrgl_offset = next_bss;
425      ptrgl_text = s->n_value;          ptrgl_text = s->n_value;
426      next_bss += 0xc;          next_bss += 0xc;
427      sym->n_scnum = DATA_NSCN;          sym->n_scnum = DATA_NSCN;
428      ((union auxent *)(sym+1))->x_csect.x_scnlen = 0xc;          ((union auxent *)(sym+1))->x_csect.x_scnlen = 0xc;
429    
430    }          }
431    
432       if(sym->n_scnum != BSS_NSCN) goto NEXT;        if(sym->n_scnum != BSS_NSCN) goto NEXT;
433       if(SYM_EXTERNAL_P(sym))        if(SYM_EXTERNAL_P(sym))
434         {int val=sym->n_value;          {int val=sym->n_value;
435          struct node joe;          struct node joe;
436          if (val && c_table.ptable)          if (val && c_table.ptable)
437            {struct node *answ;            {struct node *answ;
438             answ= find_sym(sym,0);            answ= find_sym(sym,0);
439             if(answ)            if(answ)
440               {sym->n_value = answ->address ;              {sym->n_value = answ->address ;
441                sym->n_scnum = N_UNDEF;              sym->n_scnum = N_UNDEF;
442                val= ((union auxent *)(sym+1))->x_csect.x_scnlen;              val= ((union auxent *)(sym+1))->x_csect.x_scnlen;
443                result -= val;              result -= val;
444                goto NEXT;              goto NEXT;
445              }}              }}
446        }          }
447   /* reallocate the bss space */        /* reallocate the bss space */
448   if (sym->n_value == 0)        if (sym->n_value == 0)
449     {result += ((union auxent *)(sym+1))->x_csect.x_scnlen;}          {result += ((union auxent *)(sym+1))->x_csect.x_scnlen;}
450   sym->n_value = next_bss;        sym->n_value = next_bss;
451   next_bss += ((union auxent *)(sym+1))->x_csect.x_scnlen;        next_bss += ((union auxent *)(sym+1))->x_csect.x_scnlen;
452   NEXT:      NEXT:
453   ;        ;
454       /* end aix3 */        /* end aix3 */
455  #endif  #endif
456                        
457    
458        
459  #ifdef BSD  #ifdef BSD
460       tem; /* ignored */        tem; /* ignored */
461       if(SYM_EXTERNAL_P(sym) && SYM_UNDEF_P(sym))        if(SYM_EXTERNAL_P(sym) && SYM_UNDEF_P(sym))
462  #endif  #endif
463  #ifdef COFF  #ifdef COFF
464       if(0)          if(0)
465       /* what we really want is            /* what we really want is
466          if (sym->n_scnum==0 && sym->n_sclass == C_EXT               if (sym->n_scnum==0 && sym->n_sclass == C_EXT
467                              && !(bsearch(..in ptable for this symbol)))               && !(bsearch(..in ptable for this symbol)))
468          Since this won't allow loading in of a new external array               Since this won't allow loading in of a new external array
469          char foo[10]  not ok               char foo[10]  not ok
470          static foo[10] ok.               static foo[10] ok.
471          for the moment we give undefined symbol warning..               for the moment we give undefined symbol warning..
472          Should really go through the symbols, recording the external addr               Should really go through the symbols, recording the external addr
473          for ones found in ptable, and for the ones not in ptable               for ones found in ptable, and for the ones not in ptable
474          set some flag, and add up the extra_bss required.  Then               set some flag, and add up the extra_bss required.  Then
475          when you have the new memory chunk in hand,               when you have the new memory chunk in hand,
476          you could make the pass setting the relative addresses.               you could make the pass setting the relative addresses.
477          for the ones you flagged last time.               for the ones you flagged last time.
478      */            */
479  #endif  #endif
480         /* external bss so not included in size of bss for file */            /* external bss so not included in size of bss for file */
481         {int val=sym->n_value;            {int val=sym->n_value;
482          if (val && c_table.ptable            if (val && c_table.ptable
483              && (0== find_sym(sym,0)))                && (0== find_sym(sym,0)))
484             { sym->n_value=result;              { sym->n_value=result;
485               result += val;}}              result += val;}}
486            
487       sym += NUM_AUX(sym);        sym += NUM_AUX(sym);
488    
489     }      }
490   return (result-start);    return (result-start);
491  }  }
492    
493    
# Line 485  FIND_INIT Line 496  FIND_INIT
496  to reflect the current cfd_start */  to reflect the current cfd_start */
497    
498    
499    void
500  relocate_symbols(length)  relocate_symbols(length)
501  unsigned int length;  unsigned int length;
502  {struct syment *end,*sym;  {struct syment *end,*sym;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

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