Fixup checkin of wrong source
[deliverable/binutils-gdb.git] / bfd / elf32-i386.c
index 11664ea31e80457576952d4c27a67c292fea56b0..4ad2c2be6aa4f2689613f3e4b778818503d35d1e 100644 (file)
@@ -643,16 +643,19 @@ elf_i386_check_relocs (abfd, info, sec, relocs)
             including in the link (i.e., DEF_REGULAR is set).  At
             this point we have not seen all the input files, so it is
             possible that DEF_REGULAR is not set now but will be set
-            later (it is never cleared).  We account for that
-            possibility below by storing information in the
-            pcrel_relocs_copied field of the hash table entry.
-            A similar situation occurs when creating shared libraries
-            and symbol visibility changes render the symbol local.  */
+            later (it is never cleared).  In case of a weak definition,
+            DEF_REGULAR may be cleared later by a strong definition in
+            a shared library. We account for that possibility below by
+            storing information in the relocs_copied field of the hash
+            table entry.  A similar situation occurs when creating
+            shared libraries and symbol visibility changes render the
+            symbol local.  */
          if (info->shared
              && (sec->flags & SEC_ALLOC) != 0
              && (ELF32_R_TYPE (rel->r_info) != R_386_PC32
                  || (h != NULL
                      && (! info->symbolic
+                         || h->root.type == bfd_link_hash_defweak
                          || (h->elf_link_hash_flags
                              & ELF_LINK_HASH_DEF_REGULAR) == 0))))
            {
@@ -670,9 +673,20 @@ elf_i386_check_relocs (abfd, info, sec, relocs)
                  if (name == NULL)
                    return false;
 
-                 BFD_ASSERT (strncmp (name, ".rel", 4) == 0
-                             && strcmp (bfd_get_section_name (abfd, sec),
-                                        name + 4) == 0);
+                 if (strncmp (name, ".rel", 4) != 0
+                     || strcmp (bfd_get_section_name (abfd, sec),
+                                name + 4) != 0)
+                   {
+                     if (abfd->my_archive)
+                       (*_bfd_error_handler) (_("%s(%s): bad relocation section name `%s\'"),
+                                              bfd_get_filename (abfd->my_archive),
+                                              bfd_get_filename (abfd),
+                                              name);
+                     else
+                       (*_bfd_error_handler) (_("%s: bad relocation section name `%s\'"),
+                                              bfd_get_filename (abfd),
+                                              name);
+                 }
 
                  sreloc = bfd_get_section_by_name (dynobj, name);
                  if (sreloc == NULL)
@@ -1257,7 +1271,6 @@ elf_i386_size_dynamic_sections (output_bfd, info)
    check_relocs routine, but we won't fill them in in the
    relocate_section routine.  */
 
-/*ARGSUSED*/
 static boolean
 elf_i386_discard_copies (h, inf)
      struct elf_i386_link_hash_entry *h;
@@ -1627,10 +1640,22 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
                  if (name == NULL)
                    return false;
 
-                 BFD_ASSERT (strncmp (name, ".rel", 4) == 0
-                             && strcmp (bfd_get_section_name (input_bfd,
-                                                              input_section),
-                                        name + 4) == 0);
+                 if (strncmp (name, ".rel", 4) != 0
+                     || strcmp (bfd_get_section_name (input_bfd,
+                                                      input_section),
+                                name + 4) != 0)
+                   {
+                     if (input_bfd->my_archive)
+                       (*_bfd_error_handler) (_("%s(%s): bad relocation section name `%s\'"),
+                                              bfd_get_filename (input_bfd->my_archive),
+                                              bfd_get_filename (input_bfd),
+                                              name);
+                     else
+                       (*_bfd_error_handler) (_("%s: bad relocation section name `%s\'"),
+                                              bfd_get_filename (input_bfd),
+                                              name);
+                     return false;
+                   }
 
                  sreloc = bfd_get_section_by_name (dynobj, name);
                  BFD_ASSERT (sreloc != NULL);
This page took 0.024987 seconds and 4 git commands to generate.