* xcofflink.c (xcoff_link_input_bfd): Include the .tocbss
authorGeoffrey Keating <geoffk@geoffk.org>
Wed, 6 Sep 2000 21:21:51 +0000 (21:21 +0000)
committerGeoffrey Keating <geoffk@geoffk.org>
Wed, 6 Sep 2000 21:21:51 +0000 (21:21 +0000)
  pseduo-section when determining where the TOC ends.

* coff-rs6000.c (_bfd_xcoff_swap_aux_out): Use bfd_h_put_16 to
output x_tvndx as it is only two bytes wide.

* coff-rs6000.c (xcoff_howto_table): A modifiable branch-absolute
        reloc is 26 or 32 bits wide.

* coff-rs6000.c (_bfd_xcoff_rtype2howto): The bitsize is irrelevant
        for relocs that don't change anything.  Also look at the full
        6 bits of bitsize.

bfd/ChangeLog
bfd/coff-rs6000.c
bfd/xcofflink.c

index bda321208a5ad70f47cfdd9d8149e25aabe37d4d..3da3416169ac0e0f204033acf38bfefa55b0317b 100644 (file)
@@ -1,3 +1,18 @@
+2000-09-06  Geoffrey Keating  <geoffk@cygnus.com>
+
+       * xcofflink.c (xcoff_link_input_bfd): Include the .tocbss
+       pseduo-section when determining where the TOC ends.
+
+       * coff-rs6000.c (_bfd_xcoff_swap_aux_out): Use bfd_h_put_16 to 
+       output x_tvndx as it is only two bytes wide. 
+       
+       * coff-rs6000.c (xcoff_howto_table): A modifiable branch-absolute 
+        reloc is 26 or 32 bits wide.
+       
+       * coff-rs6000.c (_bfd_xcoff_rtype2howto): The bitsize is irrelevant 
+        for relocs that don't change anything.  Also look at the full 
+        6 bits of bitsize.
+
 2000-09-06  Philip Blundell  <philb@gnu.org>
 
        * config.bfd (arm*-*-uclinux*): New target.
index dec690ce4895f237828fad3e4e37925b10b7b8c0..bd9305938fdd4b4773fce299b7274d12c9d6a743 100644 (file)
@@ -373,7 +373,7 @@ _bfd_xcoff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
   }
 
   PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
-  PUTWORD(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
+  bfd_h_put_16 (abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
 
   if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
     {
@@ -708,7 +708,7 @@ reloc_howto_type xcoff_howto_table[] =
   HOWTO (0x18,                 /* type */                                 
         0,                     /* rightshift */                           
         2,                     /* size (0 = byte, 1 = short, 2 = long) */ 
-        16,                    /* bitsize */                   
+        26,                    /* bitsize */                   
         false,                 /* pc_relative */                          
         0,                     /* bitpos */                               
         complain_overflow_bitfield, /* complain_on_overflow */
@@ -723,7 +723,7 @@ reloc_howto_type xcoff_howto_table[] =
   HOWTO (0x19,                 /* type */                                 
         0,                     /* rightshift */                           
         2,                     /* size (0 = byte, 1 = short, 2 = long) */ 
-        16,                    /* bitsize */                   
+        32,                    /* bitsize */                   
         false,                 /* pc_relative */                          
         0,                     /* bitpos */                               
         complain_overflow_bitfield, /* complain_on_overflow */
@@ -843,8 +843,11 @@ _bfd_xcoff_rtype2howto (relent, internal)
   /* The r_size field of an XCOFF reloc encodes the bitsize of the
      relocation, as well as indicating whether it is signed or not.
      Doublecheck that the relocation information gathered from the
-     type matches this information.  */
-  if (relent->howto->bitsize != ((unsigned int) internal->r_size & 0x1f) + 1)
+     type matches this information.  The bitsize is not significant 
+     for R_REF relocs.  */ 
+  if (relent->howto->dst_mask != 0 
+      && (relent->howto->bitsize  
+         != ((unsigned int) internal->r_size & 0x3f) + 1)) 
     abort ();
 #if 0
   if ((internal->r_size & 0x80) != 0
index f518fdfb1a413a77bdbd71cd2992a0f169399610..4b265cc381ab106ea23423ced1d559ea7de41dea 100644 (file)
@@ -4679,22 +4679,40 @@ xcoff_link_input_bfd (finfo, input_bfd)
          else
            {
              bfd_vma tocval, tocend;
+             bfd *inp;
 
              tocval = ((*csectpp)->output_section->vma
                        + (*csectpp)->output_offset
                        + isym.n_value
                        - (*csectpp)->vma);
+
              /* We want to find out if tocval is a good value to use
                  as the TOC anchor--that is, whether we can access all
                  of the TOC using a 16 bit offset from tocval.  This
                  test assumes that the TOC comes at the end of the
                  output section, as it does in the default linker
-                 script.  FIXME: This doesn't handle .tocbss sections
-                 created from XMC_TD common symbols correctly.  */
-
+                 script.  */
              tocend = ((*csectpp)->output_section->vma
                        + (*csectpp)->output_section->_raw_size);
-
+             for (inp = finfo->info->input_bfds; 
+                  inp != NULL; 
+                  inp = inp->link_next)
+               {
+                 asection *o;
+                 
+                 for (o = inp->sections; o != NULL; o = o->next)
+                   if (strcmp (o->name, ".tocbss") == 0)
+                     {
+                       bfd_vma new_toc_end;
+                       new_toc_end = (o->output_section->vma
+                                      + o->output_offset
+                                      + o->_cooked_size);
+                       if (new_toc_end > tocend)
+                         tocend = new_toc_end;
+                     }
+                 
+               }
+             
              if (tocval + 0x10000 < tocend)
                {
                  (*_bfd_error_handler)