This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[patch] Weak symbol support in SOM files.


I would like to submit the following patch which implements weak symbol
support in SOM files.  Please let me know if this is okay to commit.

Catherine

bfd/ChangeLog
2000-02-23  Catherine Moore  <clm@cygnus.com>
 
        * som.c (som_misc_symbol_info):  Add field
        secondary_def. 
        (som_bfd_derive_misc_symbol_info):  Initialize
        secondary_def.
        (som_build_and_write_symbol_table): Keep track
        of secondary_def field.
        (som_slurp_symbol_table): Set BSF_WEAK symbol flag
        if secondary_def field is set.
        (som_bfd_ar_write_symbol_stuff): Initialize
        secondary_def.


gas/ChangeLog

2000-02-23  Catherine Moore  <clm@cygnus.com>
 
        * config/obj-som.c (obj_pseudo_table): Add "weak".
        (obj_som_weak): New routine.

Index: som.c
===================================================================
RCS file: /cvs/src/src/bfd/som.c,v
retrieving revision 1.8
diff -p -r1.8 som.c
*** som.c	1999/12/10 18:51:35	1.8
--- som.c	2000/02/23 20:28:25
*************** struct som_misc_symbol_info
*** 148,153 ****
--- 148,154 ----
    unsigned int symbol_info;
    unsigned int symbol_value;
    unsigned int priv_level;
+   unsigned int secondary_def;
  };
  
  /* Forward declarations */
*************** som_bfd_derive_misc_symbol_info (abfd, s
*** 4052,4057 ****
--- 4053,4065 ----
  
    /* Set the symbol's value.  */
    info->symbol_value = sym->value + sym->section->vma;
+ 
+   /* The secondary_def field is for weak symbols.  */
+   if (sym->flags & BSF_WEAK)
+     info->secondary_def = true;
+   else
+     info->secondary_def = false;
+ 
  }
  
  /* Build and write, in one big chunk, the entire symbol table for
*************** som_build_and_write_symbol_table (abfd)
*** 4095,4100 ****
--- 4103,4109 ----
        som_symtab[i].symbol_info = info.symbol_info;
        som_symtab[i].xleast = 3;
        som_symtab[i].symbol_value = info.symbol_value | info.priv_level;
+       som_symtab[i].secondary_def = info.secondary_def;
      }
  
    /* Everything is ready, seek to the right location and
*************** som_slurp_symbol_table (abfd)
*** 4382,4387 ****
--- 4391,4400 ----
  	  break;
  	}
  
+       /* Check for a weak symbol.  */
+       if (bufp->secondary_def)
+         sym->symbol.flags |= BSF_WEAK;
+ 
        /* Mark section symbols and symbols used by the debugger.
  	 Note $START$ is a magic code symbol, NOT a section symbol.  */
        if (sym->symbol.name[0] == '$'
*************** som_bfd_ar_write_symbol_stuff (abfd, nsy
*** 5924,5930 ****
  
  	  /* Fill in the lst symbol record.  */
  	  curr_lst_sym->hidden = 0;
! 	  curr_lst_sym->secondary_def = 0;
  	  curr_lst_sym->symbol_type = info.symbol_type;
  	  curr_lst_sym->symbol_scope = info.symbol_scope;
  	  curr_lst_sym->check_level = 0;
--- 5937,5943 ----
  
  	  /* Fill in the lst symbol record.  */
  	  curr_lst_sym->hidden = 0;
! 	  curr_lst_sym->secondary_def = info.secondary_def;
  	  curr_lst_sym->symbol_type = info.symbol_type;
  	  curr_lst_sym->symbol_scope = info.symbol_scope;
  	  curr_lst_sym->check_level = 0;
Index: config/obj-som.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-som.c,v
retrieving revision 1.1.1.1
diff -p -r1.1.1.1 obj-som.c
*** obj-som.c	1999/05/03 07:28:42	1.1.1.1
--- obj-som.c	2000/02/23 20:28:46
***************
*** 26,36 ****
  #include "aout/stab_gnu.h"
  #include "obstack.h"
  
! /* SOM does not need any pseudo-ops.  */
  
  const pseudo_typeS obj_pseudo_table[] =
  {
!   {NULL}
  };
  
  static int version_seen = 0;
--- 26,36 ----
  #include "aout/stab_gnu.h"
  #include "obstack.h"
  
! static void obj_som_weak PARAMS ((int));
  
  const pseudo_typeS obj_pseudo_table[] =
  {
!   {"weak", obj_som_weak, 0}
  };
  
  static int version_seen = 0;
*************** som_frob_file ()
*** 305,307 ****
--- 305,339 ----
  {
    bfd_map_over_sections (stdoutput, adjust_stab_sections, (PTR) 0);
  }
+ 
+ static void
+ obj_som_weak (ignore)
+      int ignore ATTRIBUTE_UNUSED;
+ {
+   char *name;
+   int c;
+   symbolS *symbolP;
+  
+   do
+     {
+       name = input_line_pointer;
+       c = get_symbol_end ();
+       symbolP = symbol_find_or_make (name);
+       *input_line_pointer = c;
+       SKIP_WHITESPACE ();
+       S_SET_WEAK (symbolP);
+ #if 0
+       symbol_get_obj (symbolP)->local = 1;
+ #endif
+       if (c == ',')
+         {
+           input_line_pointer++;
+           SKIP_WHITESPACE ();
+           if (*input_line_pointer == '\n')
+             c = '\n';
+         }
+     }
+   while (c == ',');
+   demand_empty_rest_of_line ();
+ }
+ 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]