aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2002-10-07 16:08:21 +0000
committerNick Clifton <nickc@redhat.com>2002-10-07 16:08:21 +0000
commit53b2a62f073cd4a0ce2dbf991c06684a982f8726 (patch)
tree707de109a1db6962f2d6279dfc4132b0d6f63da3 /ld
parenta6b511bd9eef2f0ee3a91cb6c812fa6aa4d14bf8 (diff)
downloadgdb-53b2a62f073cd4a0ce2dbf991c06684a982f8726.zip
gdb-53b2a62f073cd4a0ce2dbf991c06684a982f8726.tar.gz
gdb-53b2a62f073cd4a0ce2dbf991c06684a982f8726.tar.bz2
Abort if the filename to be added matches the linker output filename.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog9
-rw-r--r--ld/ldlang.c52
-rw-r--r--ld/ldlang.h1
-rw-r--r--ld/lexsup.c32
4 files changed, 66 insertions, 28 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index ca7506a..7961079 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2002-10-05 Elias Athanasopoulos <eathan@otenet.gr>
+
+ * ldlang.c (lang_file_exist): New function.
+ (new_afile): Abort if the filename to be added matches the linker
+ output filename.
+ * ldlang.h: Add prototype for lang_file_exist.
+ * lexsup.c (parse_args): Abort if the output filename matches
+ one of the input filenames.
+
2002-10-02 Alan Modra <amodra@bigpond.net.au>
* emulparams/elf64ppc.sh (MAXPAGESIZE): Set to 0x10000.
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 6f85945..a7a3932 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -3,22 +3,22 @@
2001, 2002
Free Software Foundation, Inc.
-This file is part of GLD, the Gnu Linker.
+ This file is part of GLD, the Gnu Linker.
-GLD 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, or (at your option)
-any later version.
+ GLD 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, or (at your option)
+ any later version.
-GLD is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ GLD is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with GLD; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with GLD; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
@@ -459,6 +459,27 @@ lang_list_init (list)
list->tail = &list->head;
}
+/* Check if a file exist in the input_file_chain list. */
+
+boolean
+lang_file_exists (name)
+ const char *name;
+{
+ lang_input_statement_type *p;
+
+ if (name == NULL)
+ return false;
+
+ for (p = (lang_input_statement_type *) input_file_chain.head;
+ p != (lang_input_statement_type *) NULL;
+ p = (lang_input_statement_type *) p->next_real_file)
+ if (p->filename != (char *) NULL
+ && strcmp (p->filename, name) == 0)
+ return true;
+
+ return false;
+}
+
/* Build a new statement node for the parse tree. */
static lang_statement_union_type *
@@ -494,6 +515,11 @@ new_afile (name, file_type, target, add_to_list)
{
lang_input_statement_type *p;
+ /* We abort if an input file name is identical with the output file name. */
+ if (name != NULL && output_filename != NULL
+ && !strcmp (name, output_filename))
+ einfo ("%P%F: input file %s is also the output file!\n", name);
+
if (add_to_list)
p = new_stat (lang_input_statement, stat_ptr);
else
diff --git a/ld/ldlang.h b/ld/ldlang.h
index cb4b6d3..e587d67 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -483,5 +483,6 @@ extern void lang_register_vers_node
struct bfd_elf_version_deps *));
boolean unique_section_p PARAMS ((const char *));
extern void lang_add_unique PARAMS ((const char *));
+extern boolean lang_file_exists PARAMS ((const char *));
#endif
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 4acb4fd..69b1af2 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -3,22 +3,22 @@
2001, 2002
Free Software Foundation, Inc.
-This file is part of GLD, the Gnu Linker.
+ This file is part of GLD, the Gnu Linker.
-GLD 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, or (at your option)
-any later version.
+ GLD 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, or (at your option)
+ any later version.
-GLD is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ GLD is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with GLD; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with GLD; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
#include "bfd.h"
#include "sysdep.h"
@@ -54,8 +54,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#endif
static int is_num PARAMS ((const char *, int, int, int));
-static void set_default_dirlist PARAMS ((char *dirlist_ptr));
-static void set_section_start PARAMS ((char *sect, char *valstr));
+static void set_default_dirlist PARAMS ((char *));
+static void set_section_start PARAMS ((char *, char *));
static void help PARAMS ((void));
/* Non-zero if we are processing a --defsym from the command line. */
@@ -796,6 +796,8 @@ parse_args (argc, argv)
link_info.optimize = strtoul (optarg, NULL, 0) ? true : false;
break;
case 'o':
+ if (lang_file_exists (optarg))
+ einfo ("%P%F: output file %s is also an input file!\n", optarg);
lang_add_output (optarg, 0);
break;
case OPTION_OFORMAT: