* section.c (SEC_COFF_SHARED_LIBRARY): Renamed from
authorIan Lance Taylor <ian@airs.com>
Tue, 10 May 1994 18:29:19 +0000 (18:29 +0000)
committerIan Lance Taylor <ian@airs.com>
Tue, 10 May 1994 18:29:19 +0000 (18:29 +0000)
SEC_SHARED_LIBRARY for clarity.  Changed all uses.
* bfd-in2.h: Rebuilt.
* coffcode.h (sec_to_styp_flags): If SEC_COFF_SHARED_LIBRARY is
set, set STYP_NOLOAD.
* coffgen.c (coff_section_from_bfd_index): Don't get an assertion
failure because of a bad shared library.

bfd/ChangeLog
bfd/bfd-in2.h
bfd/coffcode.h
bfd/coffgen.c
bfd/ecoff.c

index 70ec7c7..7b04191 100644 (file)
@@ -1,3 +1,13 @@
+Tue May 10 14:23:43 1994  Ian Lance Taylor  (ian@tweedledumb.cygnus.com)
+
+       * section.c (SEC_COFF_SHARED_LIBRARY): Renamed from
+       SEC_SHARED_LIBRARY for clarity.  Changed all uses.
+       * bfd-in2.h: Rebuilt.
+       * coffcode.h (sec_to_styp_flags): If SEC_COFF_SHARED_LIBRARY is
+       set, set STYP_NOLOAD.
+       * coffgen.c (coff_section_from_bfd_index): Don't get an assertion
+       failure because of a bad shared library.
+
 Mon May  9 18:53:40 1994  Bill Cox  (bill@rtl.cygnus.com)
 
        * linker.c: Add missing comment terminator.
index 997abcd..6ea2e08 100644 (file)
@@ -463,8 +463,9 @@ void                bfd_putb32         PARAMS ((bfd_vma, unsigned char *));
 void           bfd_putl32         PARAMS ((bfd_vma, unsigned char *));
 void           bfd_putb16         PARAMS ((bfd_vma, unsigned char *));
 void           bfd_putl16         PARAMS ((bfd_vma, unsigned char *));
+\f
+/* Externally visible ECOFF routines.  */
 
-/* ECOFF linking routines.  */
 #if defined(__STDC__) || defined(ALMOST_STDC)
 struct ecoff_debug_info;
 struct ecoff_debug_swap;
@@ -472,6 +473,11 @@ struct ecoff_extr;
 struct symbol_cache_entry;
 struct bfd_link_info;
 #endif
+extern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd));
+extern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value));
+extern boolean bfd_ecoff_set_regmasks
+  PARAMS ((bfd *abfd, unsigned long gprmask, unsigned long fprmask,
+          unsigned long *cprmask));
 extern PTR bfd_ecoff_debug_init
   PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug,
           const struct ecoff_debug_swap *output_swap,
@@ -693,13 +699,19 @@ typedef struct sec
 #define SEC_HAS_CONTENTS 0x200
 
          /* An instruction to the linker to not output the section
-          even if it has information which would normally be written. */
+           even if it has information which would normally be written. */
 #define SEC_NEVER_LOAD 0x400
 
-         /* The section is a shared library section.  The linker must leave
-           these completely alone, as the vma and size are used when
-           the executable is loaded. */
-#define SEC_SHARED_LIBRARY 0x800
+         /* The section is a COFF shared library section.  This flag is
+           only for the linker.  If this type of section appears in
+           the input file, the linker must copy it to the output file
+           without changing the vma or size.  FIXME: Although this
+           was originally intended to be general, it really is COFF
+           specific (and the flag was renamed to indicate this).  It
+           might be cleaner to have some more general mechanism to
+           allow the back end to control what the linker does with
+           sections. */
+#define SEC_COFF_SHARED_LIBRARY 0x800
 
          /* The section is a common section (symbols may be defined
            multiple times, the value of a symbol is the amount of
index af015bb..4dbda14 100644 (file)
@@ -391,7 +391,7 @@ sec_to_styp_flags (sec_name, sec_flags)
     }
 
 #ifdef STYP_NOLOAD
-  if (sec_flags & SEC_NEVER_LOAD)
+  if ((sec_flags & (SEC_NEVER_LOAD | SEC_COFF_SHARED_LIBRARY)) != 0)
     styp_flags |= STYP_NOLOAD;
 #endif
 
@@ -425,14 +425,14 @@ styp_to_sec_flags (abfd, hdr)
   if (styp_flags & STYP_TEXT)
     {
       if (sec_flags & SEC_NEVER_LOAD)
-       sec_flags |= SEC_CODE | SEC_SHARED_LIBRARY;
+       sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
       else
        sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
     }
   else if (styp_flags & STYP_DATA)
     {
       if (sec_flags & SEC_NEVER_LOAD)
-       sec_flags |= SEC_DATA | SEC_SHARED_LIBRARY;
+       sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
       else
        sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
     }
@@ -440,7 +440,7 @@ styp_to_sec_flags (abfd, hdr)
     {
 #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
       if (sec_flags & SEC_NEVER_LOAD)
-       sec_flags |= SEC_ALLOC | SEC_SHARED_LIBRARY;
+       sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
       else
 #endif
        sec_flags |= SEC_ALLOC;
@@ -755,6 +755,14 @@ coff_new_section_hook (abfd, section)
   coffsymbol (section->symbol)->native =
     (combined_entry_type *) bfd_zalloc (abfd,
                                        sizeof (combined_entry_type) * 10);
+
+#ifdef COFF_SPARC
+  /* This is to allow double-word operations on addresses in data or bss. */
+  if (strcmp (section->name, ".data") == 0
+      || strcmp (section->name, ".bss") == 0)
+    section->alignment_power = 3;
+#endif /* COFF_SPARC */
+
   return true;
 }
 
@@ -982,8 +990,8 @@ coff_set_arch_mach_hook (abfd, filehdr)
       break;
 #endif
 
-#ifdef SHMAGIC
-    case SHMAGIC:
+#ifdef SH_ARCH_MAGIC
+    case SH_ARCH_MAGIC:
       arch = bfd_arch_sh;
       machine = 0;
       break;
@@ -998,6 +1006,9 @@ coff_set_arch_mach_hook (abfd, filehdr)
 
 #ifdef SPARCMAGIC
     case SPARCMAGIC:
+#ifdef LYNXCOFFMAGIC
+    case LYNXCOFFMAGIC:
+#endif
       arch = bfd_arch_sparc;
       machine = 0;
       break;
@@ -1220,9 +1231,9 @@ coff_set_flags (abfd, magicp, flagsp)
       break;
 #endif
 
-#ifdef SHMAGIC
+#ifdef SH_ARCH_MAGIC
     case bfd_arch_sh:
-      *magicp = SHMAGIC;
+      *magicp = SH_ARCH_MAGIC;
       return true;
       break;
 #endif
@@ -1287,11 +1298,14 @@ coff_set_arch_mach (abfd, arch, machine)
 {
   unsigned dummy1;
   unsigned short dummy2;
-  bfd_default_set_arch_mach (abfd, arch, machine);
+
+  if (! bfd_default_set_arch_mach (abfd, arch, machine))
+    return false;
 
   if (arch != bfd_arch_unknown &&
       coff_set_flags (abfd, &dummy1, &dummy2) != true)
     return false;              /* We can't represent this type */
+
   return true;                 /* We're easy ... */
 }
 
index d7fd2af..3542ded 100644 (file)
@@ -105,7 +105,7 @@ make_a_section_from_file (abfd, hdr, target_index)
 
   /* At least on i386-coff, the line number count for a shared library
      section must be ignored.  */
-  if ((return_section->flags & SEC_SHARED_LIBRARY) != 0)
+  if ((return_section->flags & SEC_COFF_SHARED_LIBRARY) != 0)
     return_section->lineno_count = 0;
 
   if (hdr->s_nreloc != 0)
@@ -240,7 +240,9 @@ coff_object_p (abfd)
   }
 
   /* Seek past the opt hdr stuff */
-  bfd_seek(abfd, (file_ptr) (internal_f.f_opthdr + filhsz), SEEK_SET);
+  if (bfd_seek(abfd, (file_ptr) (internal_f.f_opthdr + filhsz), SEEK_SET)
+      != 0)
+    return NULL;
 
   return coff_real_object_p(abfd, nscns, &internal_f,
                            (internal_f.f_opthdr != 0
@@ -276,8 +278,10 @@ coff_section_from_bfd_index (abfd, index)
        return answer;
       answer = answer->next;
     }
-  BFD_ASSERT(0);
-  return &bfd_und_section;     /* For gcc -W and lint.  Never executed. */
+
+  /* We should not reach this point, but the SCO 3.2v4 /lib/libc_s.a
+     has a bad symbol table in biglitpow.o.  */
+  return &bfd_und_section;
 }
 
 /* Get the upper bound of a COFF symbol table.  */
@@ -916,7 +920,8 @@ coff_write_symbols (abfd)
      bfd_byte buffer[4];
 
      bfd_h_put_32 (abfd, size, buffer);
-     bfd_write ((PTR) buffer, 1, sizeof (buffer), abfd);
+     if (bfd_write ((PTR) buffer, 1, sizeof (buffer), abfd) != sizeof (buffer))
+       return false;
      for (p = abfd->outsymbols, i = 0;
          i < limit;
          i++, p++)
@@ -1005,7 +1010,8 @@ coff_write_linenumbers (abfd)
   for (s = abfd->sections; s != (asection *) NULL; s = s->next) {
     if (s->lineno_count) {
       asymbol       **q = abfd->outsymbols;
-      bfd_seek(abfd, s->line_filepos, SEEK_SET);
+      if (bfd_seek(abfd, s->line_filepos, SEEK_SET) != 0)
+       return false;
       /* Find all the linenumbers in this section */
       while (*q) {
        asymbol        *p = *q;
@@ -1019,13 +1025,15 @@ coff_write_linenumbers (abfd)
            out.l_lnno = 0;
            out.l_addr.l_symndx = l->u.offset;
            bfd_coff_swap_lineno_out(abfd, &out, buff);
-           bfd_write(buff, 1, linesz, abfd);
+           if (bfd_write(buff, 1, linesz, abfd) != linesz)
+             return false;
            l++;
            while (l->line_number) {
              out.l_lnno = l->line_number;
              out.l_addr.l_symndx = l->u.offset;
              bfd_coff_swap_lineno_out(abfd, &out, buff);
-             bfd_write(buff, 1, linesz, abfd);
+             if (bfd_write(buff, 1, linesz, abfd) != linesz)
+               return false;
              l++;
            }
          }
@@ -1180,12 +1188,12 @@ build_debug_section (abfd)
      Then read debug section and reset the file pointer.  */
 
   position = bfd_tell (abfd);
-  bfd_seek (abfd, sect->filepos, SEEK_SET);
-  if (bfd_read (debug_section, 
-               bfd_get_section_size_before_reloc (sect), 1, abfd)
-      != bfd_get_section_size_before_reloc(sect))
+  if (bfd_seek (abfd, sect->filepos, SEEK_SET) != 0
+      || (bfd_read (debug_section, 
+                   bfd_get_section_size_before_reloc (sect), 1, abfd)
+         != bfd_get_section_size_before_reloc(sect))
+      || bfd_seek (abfd, position, SEEK_SET) != 0)
     return NULL;
-  bfd_seek (abfd, position, SEEK_SET);
   return debug_section;
 }
 
index ce4d5f6..ba5214c 100644 (file)
@@ -174,7 +174,7 @@ ecoff_new_section_hook (abfd, section)
   else if (strcmp (section->name, _LIB) == 0)
     {
       /* An Irix 4 shared libary.  */
-      section->flags |= SEC_SHARED_LIBRARY;
+      section->flags |= SEC_COFF_SHARED_LIBRARY;
     }
 
   /* Probably any other section name is SEC_NEVER_LOAD, but I'm
@@ -356,7 +356,7 @@ ecoff_styp_to_sec_flags (abfd, hdr)
       || (styp_flags & STYP_ECOFF_FINI))
     {
       if (sec_flags & SEC_NEVER_LOAD)
-       sec_flags |= SEC_CODE | SEC_SHARED_LIBRARY;
+       sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
       else
        sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
     }
@@ -367,7 +367,7 @@ ecoff_styp_to_sec_flags (abfd, hdr)
           || styp_flags == STYP_XDATA)
     {
       if (sec_flags & SEC_NEVER_LOAD)
-       sec_flags |= SEC_DATA | SEC_SHARED_LIBRARY;
+       sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
       else
        sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
       if ((styp_flags & STYP_RDATA)
@@ -391,7 +391,7 @@ ecoff_styp_to_sec_flags (abfd, hdr)
     }
   else if (styp_flags & STYP_ECOFF_LIB)
     {
-      sec_flags |= SEC_SHARED_LIBRARY;
+      sec_flags |= SEC_COFF_SHARED_LIBRARY;
     }
   else
     {