* scripttempl/armbpabi.sc (ENTRY): Do not define when performing a
[deliverable/binutils-gdb.git] / ld / deffilep.y
index 5dc26c6cb397bc17d883f99d768515e0073a11ba..4f17f506654288858d644f12f694356bfe038e6c 100644 (file)
@@ -1,13 +1,13 @@
 %{ /* deffilep.y - parser for .def files */
 
-/*   Copyright 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+/*   Copyright 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007
      Free Software Foundation, Inc.
 
      This file is part of GNU Binutils.
 
      This program is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
-     the Free Software Foundation; either version 2 of the License, or
+     the Free Software Foundation; either version 3 of the License, or
      (at your option) any later version.
 
      This program is distributed in the hope that it will be useful,
 
      You should have received a copy of the GNU General Public License
      along with this program; if not, write to the Free Software
-     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+     Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+     MA 02110-1301, USA.  */
 
-#include <stdio.h>
+#include "sysdep.h"
 #include "libiberty.h"
 #include "safe-ctype.h"
 #include "bfd.h"
-#include "sysdep.h"
 #include "ld.h"
 #include "ldmisc.h"
 #include "deffile.h"
@@ -648,13 +648,30 @@ def_file_add_directive (def_file *my_def, const char *param, int len)
 static void
 def_image_name (const char *name, int base, int is_dll)
 {
-  const char* image_name = lbasename (name);
-  if (image_name != name)
-    einfo ("%s:%d: Warning: path components stripped from %s, '%s'\n",
-         def_filename, linenumber, is_dll ? "LIBRARY" : "NAME", name);
-  if (def->name)
-    free (def->name);
-  def->name = xstrdup (image_name);
+  /* If a LIBRARY or NAME statement is specified without a name, there is nothing
+     to do here.  We retain the output filename specified on command line.  */
+  if (*name)
+    {
+      const char* image_name = lbasename (name);
+      if (image_name != name)
+       einfo ("%s:%d: Warning: path components stripped from %s, '%s'\n",
+              def_filename, linenumber, is_dll ? "LIBRARY" : "NAME",
+              name);
+      if (def->name)
+       free (def->name);
+      /* Append the default suffix, if none specified.  */ 
+      if (strchr (image_name, '.') == 0)
+       {
+         const char * suffix = is_dll ? ".dll" : ".exe";
+
+         def->name = xmalloc (strlen (image_name) + strlen (suffix) + 1);
+         sprintf (def->name, "%s%s", image_name, suffix);
+        }
+      else
+       def->name = xstrdup (image_name);
+    }
+
+  /* Honor a BASE address statement, even if LIBRARY string is empty.  */
   def->base_address = base;
   def->is_dll = is_dll;
 }
This page took 0.024672 seconds and 4 git commands to generate.