* pe-dll.c (process_def_file): auto-export everything if
[deliverable/binutils-gdb.git] / ld / ldlang.c
index feee32479bc13ec03ef1610f9c645ed6496f9d43..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);
+
+                     for (pp = &ptr->children.head;
+                          *pp != before;
+                          pp = &(*pp)->next)
+                       ASSERT (*pp != NULL);
 
-                 list.head->next = *pp;
-                 *pp = list.head;
+                     list.head->next = *pp;
+                     *pp = list.head;
+                   }
                }
            }
        }
@@ -3692,21 +3743,6 @@ lang_section_start (name, address)
    called by ENTRY in a linker script.  Command line arguments take
    precedence.  */
 
-/* WINDOWS_NT.  When an entry point has been specified, we will also force
-   this symbol to be defined by calling ldlang_add_undef (equivalent to 
-   having switch -u entry_name on the command line).  The reason we do
-   this is so that the user doesn't have to because they would have to use
-   the -u switch if they were specifying an entry point other than 
-   _mainCRTStartup.  Specifically, if creating a windows application, entry
-   point _WinMainCRTStartup must be specified.
-     What I have found for non console applications (entry not _mainCRTStartup)
-   is that the .obj that contains mainCRTStartup is brought in since it is
-   the first encountered in libc.lib and it has other symbols in it which will
-   be pulled in by the link process.  To avoid this, adding -u with the entry
-   point name specified forces the correct .obj to be used.  We can avoid
-   making the user do this by always adding the entry point name as an
-   undefined symbol.  */
-
 void
 lang_add_entry (name, cmdline)
      CONST char *name;
@@ -3719,14 +3755,6 @@ lang_add_entry (name, cmdline)
       entry_symbol = name;
       entry_from_cmdline = cmdline;
     }
-#if 0 
-  /* don't do this yet.  It seems to work (the executables run), but the 
-     image created is very different from what I was getting before indicating
-     that something else is being pulled in.  When everything else is working,
-     then try to put this back in to see if it will do the right thing for
-     other more complicated applications */
-  ldlang_add_undef (name);
-#endif
 }
 
 void
@@ -4214,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.024782 seconds and 4 git commands to generate.