aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog12
-rw-r--r--ld/ldfile.c14
-rw-r--r--ld/ldlang.c1
-rw-r--r--ld/ldmain.c35
-rw-r--r--ld/ldmisc.c31
-rw-r--r--ld/lexsup.c8
6 files changed, 65 insertions, 36 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 5a547ff..ea55dbe 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,15 @@
+2003-03-31 David Heine <dlheine@suif.stanford.edu>
+
+ * ldfile.c (ldfile_add_library_path): Always allocate space for
+ the filename.
+ * ldlang.c (lang_register_vers_node): Free the node if it cannot
+ be used.
+ * ldmain.c (set_scripts_dir): Always free the constructed
+ directory name.
+ (add_keepsyms_file): Fix memory leak.
+ * ldmisc.c (vfinfo): Likewise.
+ * lexsup.c (parse_args): Likewise
+
2003-03-25 Stan Cox <scox@redhat.com>
Nick Clifton <nickc@redhat.com>
diff --git a/ld/ldfile.c b/ld/ldfile.c
index fbcd7b9..0694f9b 100644
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -106,32 +106,38 @@ is_sysrooted_pathname (name, notsame)
return result;
}
+/* Adds NAME to the library search path.
+ Makes a copy of NAME using xmalloc(). */
+
void
ldfile_add_library_path (name, cmdline)
const char *name;
bfd_boolean cmdline;
{
search_dirs_type *new;
+ char *newname;
if (!cmdline && config.only_cmd_line_lib_dirs)
return;
new = (search_dirs_type *) xmalloc (sizeof (search_dirs_type));
new->next = NULL;
- new->name = name;
new->cmdline = cmdline;
*search_tail_ptr = new;
search_tail_ptr = &new->next;
/* If a directory is marked as honoring sysroot, prepend the sysroot path
now. */
- if (new->name[0] == '=')
+ if (name[0] == '=')
{
- new->name = concat (ld_sysroot, &new->name[1], NULL);
+ new->name = concat (ld_sysroot, name + 1, NULL);
new->sysrooted = TRUE;
}
else
- new->sysrooted = is_sysrooted_pathname (new->name, FALSE);
+ {
+ new->name = xstrdup (name);
+ new->sysrooted = is_sysrooted_pathname (name, FALSE);
+ }
}
/* Try to open a BFD for a lang_input_statement. */
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 703779f..5cca71f 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -5276,6 +5276,7 @@ lang_register_vers_node (name, version, deps)
|| (lang_elf_version_info && lang_elf_version_info->name[0] == '\0'))
{
einfo (_("%X%P: anonymous version tag cannot be combined with other version tags\n"));
+ free (version);
return;
}
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 284b975..125dc6a 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -672,22 +672,25 @@ set_scripts_dir ()
{
char *end, *dir;
size_t dirlen;
+ bfd_boolean found;
dir = make_relative_prefix (program_name, BINDIR, SCRIPTDIR);
- if (dir && check_for_scripts_dir (dir))
- /* Success. Don't free dir. */
- return;
-
if (dir)
- free (dir);
+ {
+ found = check_for_scripts_dir (dir);
+ free (dir);
+ if (found)
+ return;
+ }
dir = make_relative_prefix (program_name, TOOLBINDIR, SCRIPTDIR);
- if (dir && check_for_scripts_dir (dir))
- /* Success. Don't free dir. */
- return;
-
if (dir)
- free (dir);
+ {
+ found = check_for_scripts_dir (dir);
+ free (dir);
+ if (found)
+ return;
+ }
if (check_for_scripts_dir (SCRIPTDIR))
/* We've been installed normally. */
@@ -718,15 +721,14 @@ set_scripts_dir ()
dir[dirlen] = '\0';
if (check_for_scripts_dir (dir))
- /* Don't free dir. */
- return;
+ {
+ free (dir);
+ return;
+ }
/* Look for "ldscripts" in <the dir where our binary is>/../lib. */
strcpy (dir + dirlen, "/../lib");
- if (check_for_scripts_dir (dir))
- return;
-
- /* Well, we tried. */
+ check_for_scripts_dir (dir);
free (dir);
}
@@ -832,6 +834,7 @@ add_keepsyms_file (filename)
if (link_info.strip != strip_none)
einfo (_("%P: `-retain-symbols-file' overrides `-s' and `-S'\n"));
+ free (buf);
link_info.strip = strip_some;
}
diff --git a/ld/ldmisc.c b/ld/ldmisc.c
index 94b03d4..4f25dbb 100644
--- a/ld/ldmisc.c
+++ b/ld/ldmisc.c
@@ -1,25 +1,25 @@
/* ldmisc.c
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2002
+ 2000, 2002, 2003
Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support.
-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"
@@ -328,6 +328,9 @@ vfinfo (fp, fmt, arg)
fprintf (fp, ":%u", linenumber);
}
+ if (asymbols != NULL && entry == NULL)
+ free (asymbols);
+
if (discard_last)
{
last_bfd = NULL;
diff --git a/ld/lexsup.c b/ld/lexsup.c
index b6c2fd8..e8c2eba 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -1116,6 +1116,8 @@ parse_args (argc, argv)
case 'Y':
if (strncmp (optarg, "P,", 2) == 0)
optarg += 2;
+ if (default_dirlist != NULL)
+ free (default_dirlist);
default_dirlist = xstrdup (optarg);
break;
case 'y':
@@ -1193,8 +1195,10 @@ parse_args (argc, argv)
lang_leave_group ();
if (default_dirlist != NULL)
- set_default_dirlist (default_dirlist);
-
+ {
+ set_default_dirlist (default_dirlist);
+ free (default_dirlist);
+ }
}
/* Add the (colon-separated) elements of DIRLIST_PTR to the