* pe-dll.c (process_def_file): auto-export everything if
[deliverable/binutils-gdb.git] / ld / ldlang.c
index 56b42948a1eaf5933d5f28932fa25226dc6c34e2..2106b3e90874f82e5ae22570c52e56ca28bac758 100644 (file)
@@ -993,13 +993,58 @@ wild_sort (wild, file, section)
 
       if (wild->filenames_sorted)
        {
+         const char *fn, *ln;
+         boolean fa, la;
          int i;
 
-         i = strcmp (file->filename, ls->ifile->filename);
+         /* The PE support for the .idata section as generated by
+             dlltool assumes that files will be sorted by the name of
+             the archive and then the name of the file within the
+             archive.  */
+
+         if (file->the_bfd != NULL
+             && bfd_my_archive (file->the_bfd) != NULL)
+           {
+             fn = bfd_get_filename (bfd_my_archive (file->the_bfd));
+             fa = true;
+           }
+         else
+           {
+             fn = file->filename;
+             fa = false;
+           }
+
+         if (ls->ifile->the_bfd != NULL
+             && bfd_my_archive (ls->ifile->the_bfd) != NULL)
+           {
+             ln = bfd_get_filename (bfd_my_archive (ls->ifile->the_bfd));
+             la = true;
+           }
+         else
+           {
+             ln = ls->ifile->filename;
+             la = false;
+           }
+
+         i = strcmp (fn, ln);
          if (i > 0)
            continue;
          else if (i < 0)
            break;
+
+         if (fa || la)
+           {
+             if (fa)
+               fn = file->filename;
+             if (la)
+               ln = ls->ifile->filename;
+
+             i = strcmp (fn, ln);
+             if (i > 0)
+               continue;
+             else if (i < 0)
+               break;
+           }
        }
 
       /* Here either the files are not sorted by name, or we are
@@ -1088,15 +1133,21 @@ wild_section (ptr, section, file, output)
 
                  lang_list_init (&list);
                  wild_doit (&list, s, output, file);
-                 ASSERT (list.head != NULL && list.head->next == NULL);
 
-                 for (pp = &ptr->children.head;
-                      *pp != before;
-                      pp = &(*pp)->next)
-                   ASSERT (*pp != NULL);
+                 /* If we are discarding the section, LIST.HEAD will
+                     be NULL.  */
+                 if (list.head != NULL)
+                   {
+                     ASSERT (list.head->next == NULL);
 
-                 list.head->next = *pp;
-                 *pp = list.head;
+                     for (pp = &ptr->children.head;
+                          *pp != before;
+                          pp = &(*pp)->next)
+                       ASSERT (*pp != NULL);
+
+                     list.head->next = *pp;
+                     *pp = list.head;
+                   }
                }
            }
        }
@@ -4191,7 +4242,7 @@ lang_enter_overlay_section (name)
   if (overlay_max == NULL)
     overlay_max = size;
   else
-    overlay_max = exp_binop (MAX, overlay_max, size);
+    overlay_max = exp_binop (MAX_K, overlay_max, size);
 }
 
 /* Finish a section in an overlay.  There isn't any special to do
This page took 0.024001 seconds and 4 git commands to generate.