1999-07-23 Donn Terry <donn@interix.com>
authorIan Lance Taylor <ian@airs.com>
Sat, 24 Jul 1999 03:16:50 +0000 (03:16 +0000)
committerIan Lance Taylor <ian@airs.com>
Sat, 24 Jul 1999 03:16:50 +0000 (03:16 +0000)
* libcoff-in.h (coff_link_hash_entry): Add coff_link_hash_flags
field, and define COFF_LINK_HASH_PE_SECTION_SYMBOL.
* cofflink.c (coff_link_add_symbols): If PE, handle section
symbols specially.
* libcoff.h: Rebuild.

bfd/ChangeLog
bfd/cofflink.c
bfd/libcoff-in.h
bfd/libcoff.h

index 53a08c4532532d3caa38257348b1231329c7fb6b..e013fb5d4e4b55798420c4d9723b13deee3f494f 100644 (file)
@@ -1,5 +1,11 @@
 1999-07-23  Donn Terry  <donn@interix.com>
 
+       * libcoff-in.h (coff_link_hash_entry): Add coff_link_hash_flags
+       field, and define COFF_LINK_HASH_PE_SECTION_SYMBOL.
+       * cofflink.c (coff_link_add_symbols): If PE, handle section
+       symbols specially.
+       * libcoff.h: Rebuild.
+
        * config.bfd (i[3456]86-*-interix*): New target.
 
 1999-07-21  Mark Elbrecht  <snowball3@bigfoot.com>
index 679e7a84d87abf5c485b498d7f4958246cfa229f..f8748327f33dc8a0d1ce79a8c492e13db1d6cb7e 100644 (file)
@@ -351,6 +351,7 @@ coff_link_add_symbols (abfd, info)
          flagword flags;
          asection *section;
          bfd_vma value;
+         boolean addit;
 
          /* This symbol is externally visible.  */
 
@@ -392,11 +393,41 @@ coff_link_add_symbols (abfd, info)
              || (obj_pe (abfd) && sym.n_sclass == C_NT_WEAK))
            flags = BSF_WEAK;
 
-         if (! (bfd_coff_link_add_one_symbol
-                (info, abfd, name, flags, section, value,
-                 (const char *) NULL, copy, false,
-                 (struct bfd_link_hash_entry **) sym_hash)))
-           goto error_return;
+         addit = true;
+
+         /* In the PE format, section symbols actually refer to the
+             start of the output section.  We handle them specially
+             here.  */
+         if (obj_pe (abfd) && (flags & BSF_SECTION_SYM) != 0)
+           {
+             *sym_hash = coff_link_hash_lookup (coff_hash_table (info),
+                                                name, false, copy, false);
+             if (*sym_hash != NULL)
+               {
+                 if (((*sym_hash)->coff_link_hash_flags
+                      & COFF_LINK_HASH_PE_SECTION_SYMBOL) == 0
+                     && (*sym_hash)->root.type != bfd_link_hash_undefined
+                     && (*sym_hash)->root.type != bfd_link_hash_undefweak)
+                   (*_bfd_error_handler)
+                     ("Warning: symbol `%s' is both section and non-section",
+                      name);
+
+                 addit = false;
+               }
+           }
+
+         if (addit)
+           {
+             if (! (bfd_coff_link_add_one_symbol
+                    (info, abfd, name, flags, section, value,
+                     (const char *) NULL, copy, false,
+                     (struct bfd_link_hash_entry **) sym_hash)))
+               goto error_return;
+           }
+
+         if (obj_pe (abfd) && (flags & BSF_SECTION_SYM) != 0)
+           (*sym_hash)->coff_link_hash_flags |=
+             COFF_LINK_HASH_PE_SECTION_SYMBOL;
 
          if (section == bfd_com_section_ptr
              && (*sym_hash)->root.type == bfd_link_hash_common
index 0dc2121c9813ff7b171e922799231721b1c6166e..dae881f288c793084e8ebde279c471931beb4149 100644 (file)
@@ -249,6 +249,11 @@ struct coff_link_hash_entry
 
   /* Pointer to array of auxiliary entries, if any.  */
   union internal_auxent *aux;
+
+  /* Flag word; legal values follow.  */
+  unsigned short coff_link_hash_flags;
+  /* Symbol is a PE section symbol.  */
+#define COFF_LINK_HASH_PE_SECTION_SYMBOL (01)
 };
 
 /* COFF linker hash table.  */
index c418a4d4667aeab51802522226fb838469e148bc..0eebf5ffb9945cc8b46a3a90605e5b28cb31c3a0 100644 (file)
@@ -249,6 +249,11 @@ struct coff_link_hash_entry
 
   /* Pointer to array of auxiliary entries, if any.  */
   union internal_auxent *aux;
+
+  /* Flag word; legal values follow.  */
+  unsigned short coff_link_hash_flags;
+  /* Symbol is a PE section symbol.  */
+#define COFF_LINK_HASH_PE_SECTION_SYMBOL (01)
 };
 
 /* COFF linker hash table.  */