* cofflink.c (_bfd_coff_final_link): On PE COFF systems, take into
authorMark Mitchell <mark@codesourcery.com>
Mon, 8 Jul 2002 05:34:08 +0000 (05:34 +0000)
committerMark Mitchell <mark@codesourcery.com>
Mon, 8 Jul 2002 05:34:08 +0000 (05:34 +0000)
account the impact of relocation count overflow when computing
section offsets.
* coffcode.h (coff_write_relocs): Use obj_pe when deciding whether
or not to apply the PE COFF reloc overflow handling.  Fix a
fencepost error in deciding whether or not to use that technique.

bfd/ChangeLog
bfd/coffcode.h
bfd/cofflink.c

index 0e66cda7c883ab462fe9f08ed5ff13e1e6b774b1..2e442bafbba7bbd303e4ef764f9add93b3e69798 100644 (file)
@@ -1,3 +1,13 @@
+2002-07-07  Mark Mitchell  <mark@codesourcery.com>
+           Alan Modra  <amodra@bigpond.net.au>
+
+       * cofflink.c (_bfd_coff_final_link): On PE COFF systems, take into
+       account the impact of relocation count overflow when computing
+       section offsets.
+       * coffcode.h (coff_write_relocs): Use obj_pe when deciding whether
+       or not to apply the PE COFF reloc overflow handling.  Fix a
+       fencepost error in deciding whether or not to use that technique.
+
 2002-07-07  Alan Modra  <amodra@bigpond.net.au>
 
        * elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx,
index 6040026c9e9af415f2ccf53501d56cae10dfee76..bb777aaaf183bc6f3ac004a1db1f09f5567a99ea 100644 (file)
@@ -2394,7 +2394,7 @@ coff_write_relocs (abfd, first_undef)
        return false;
 
 #ifdef COFF_WITH_PE
-      if (s->reloc_count > 0xffff)
+      if (obj_pe (abfd) && s->reloc_count >= 0xffff)
        {
          /* encode real count here as first reloc */
          struct internal_reloc n;
@@ -3420,7 +3420,7 @@ coff_write_object_contents (abfd)
     {
 #ifdef COFF_WITH_PE
       /* we store the actual reloc count in the first reloc's addr */
-      if (current->reloc_count > 0xffff)
+      if (obj_pe (abfd) && current->reloc_count >= 0xffff)
        reloc_count ++;
 #endif
       reloc_count += current->reloc_count;
@@ -3451,7 +3451,7 @@ coff_write_object_contents (abfd)
          reloc_base += current->reloc_count * bfd_coff_relsz (abfd);
 #ifdef COFF_WITH_PE
          /* extra reloc to hold real count */
-         if (current->reloc_count > 0xffff)
+         if (obj_pe (abfd) && current->reloc_count >= 0xffff)
            reloc_base += bfd_coff_relsz (abfd);
 #endif
        }
index 32200a83a63502c6122e0826aa59d46a061e5f4a..eb9388fc71ed5d4ad35adc687968317573715ce7 100644 (file)
@@ -757,6 +757,10 @@ _bfd_coff_final_link (abfd, info)
          o->flags |= SEC_RELOC;
          o->rel_filepos = rel_filepos;
          rel_filepos += o->reloc_count * relsz;
+         /* In PE COFF, if there are at least 0xffff relocations an
+            extra relocation will be written out to encode the count.  */
+         if (obj_pe (abfd) && o->reloc_count >= 0xffff)
+           rel_filepos += relsz;
        }
 
       if (bfd_coff_long_section_names (abfd)
This page took 0.033042 seconds and 4 git commands to generate.