+2003-03-31 David Heine <dlheine@suif.stanford.edu>
+
+ * aoutx.h (aout_link_hash_table_create): Use bfd_malloc instead of
+ bfd_alloc.
+ * dwarf2.c (concat_filename): Always allocate space for the
+ returned filename.
+ (decode_line_info): Free the allocated filename returned by
+ concat_filename.
+ * elf-eh-frame.c (bfd_elf_write_section_eh_frame): Fix memory leaks.
+ * elf.c (copy_private_bfd_data): Likewise.
+ (_bfd_elf_slurp_version_tables): Fix bug freeing contents pointer.
+ * elflink.h (elf_link_sort_relocs): Fix memory leak.
+ * format.c (bfd_check_format_matches): Likewise.
+ * linker.c (bfd_generic_final_link): Likewise.
+ * opncls.c (find_separate_debug_info): Likewise.
+ * simple.c (bfd_simple_get_relocated_section_contents): Likewise.
+
2003-03-28 H.J. Lu <hjl@gnu.org>
* elflink.h (elf_link_add_object_symbols): Correctly combine
/* BFD semi-generic back-end for a.out binaries.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
- 2001, 2002
+ 2001, 2002, 2003
Free Software Foundation, Inc.
Written by Cygnus Support.
in the @file{config/@var{XXX}.mt} file, and modify @file{configure.in}
to use the
@file{@var{XXX}.mt} file (by setting "<<bfd_target=XXX>>") when your
- configuration is selected.
-
-*/
+ configuration is selected. */
/* Some assumptions:
* Any BFD with D_PAGED set is ZMAGIC, and vice versa.
The standard records contain only an
address, a symbol index, and a type field. The extended records
(used on 29ks and sparcs) also have a full integer for an
- addend.
+ addend. */
-*/
#ifndef CTOR_TABLE_RELOC_HOWTO
#define CTOR_TABLE_RELOC_IDX 2
#define CTOR_TABLE_RELOC_HOWTO(BFD) \
/* Convert standard reloc records to "arelent" format (incl byte swap). */
-reloc_howto_type howto_table_std[] = {
+reloc_howto_type howto_table_std[] =
+{
/* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone. */
HOWTO ( 0, 0, 0, 8, FALSE, 0, complain_overflow_bitfield,0,"8", TRUE, 0x000000ff,0x000000ff, FALSE),
HOWTO ( 1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield,0,"16", TRUE, 0x0000ffff,0x0000ffff, FALSE),
struct aout_link_hash_table *ret;
bfd_size_type amt = sizeof (struct aout_link_hash_table);
- ret = (struct aout_link_hash_table *) bfd_alloc (abfd, amt);
+ ret = (struct aout_link_hash_table *) bfd_malloc (amt);
if (ret == NULL)
return (struct bfd_link_hash_table *) NULL;
+
if (! NAME(aout,link_hash_table_init) (ret, abfd,
NAME(aout,link_hash_newfunc)))
{
for (o = abfd->sections; o != NULL; o = o->next)
{
for (p = o->link_order_head; p != NULL; p = p->next)
- {
- if (p->type == bfd_indirect_link_order)
- p->u.indirect.section->linker_mark = TRUE;
- }
+ if (p->type == bfd_indirect_link_order)
+ p->u.indirect.section->linker_mark = TRUE;
}
have_link_order_relocs = FALSE;
/* DWARF 2 support.
- Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+ Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
Adapted from gdb/dwarf2read.c by Gavin Koch of Cygnus Solutions
info->end_sequence = end_sequence;
}
+/* Extract a fully qualified filename from a line info table.
+ The returned string has been xmalloc'ed. */
+
static char *
concat_filename (table, file)
struct line_info_table* table;
{
(*_bfd_error_handler)
(_("Dwarf Error: mangled line number section (bad file number)."));
- return "<unknown>";
+ return concat ("<unknown>");
}
filename = table->files[file - 1].name;
- if (IS_ABSOLUTE_PATH(filename))
- return filename;
+
+ if (IS_ABSOLUTE_PATH (filename))
+ return concat (filename);
else
{
char* dirname = (table->files[file - 1].dir
/* Not all tools set DW_AT_comp_dir, so dirname may be unknown. The
best we can do is return the filename part. */
if (dirname == NULL)
- return filename;
+ return concat (filename);
else
- return (char*) concat (dirname, "/", filename, NULL);
+ return concat (dirname, "/", filename, NULL);
}
}
based, the references are 1 based. */
file = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
line_ptr += bytes_read;
+ free (filename);
filename = concat_filename (table, file);
break;
}
default:
{
int i;
+
/* Unknown standard opcode, ignore it. */
for (i = 0; i < lh.standard_opcode_lengths[op_code]; i++)
{
}
}
}
+
+ free (filename);
}
return table;
Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
Written by Jakub Jelinek <jakub@redhat.com>.
-This file is part of BFD, the Binary File Descriptor library.
+ This file is part of BFD, the Binary File Descriptor library.
-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
-(at your option) any later version.
+ 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
+ (at your option) any later version.
-This program 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.
+ This program 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 this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ 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. */
#include "bfd.h"
#include "sysdep.h"
static int cie_compare
PARAMS ((struct cie *, struct cie *));
static int vma_compare
- PARAMS ((const PTR a, const PTR b));
+ PARAMS ((const PTR, const PTR));
/* Helper function for reading uleb128 encoded data. */
fde_count x [encoded] initial_loc, fde
(array of encoded pairs containing
FDE initial_location field and FDE address,
- sorted by increasing initial_loc) */
+ sorted by increasing initial_loc). */
bfd_boolean
_bfd_elf_write_section_eh_frame_hdr (abfd, info)
bfd_byte *contents;
asection *eh_frame_sec;
bfd_size_type size;
+ bfd_boolean retval;
htab = elf_hash_table (info);
hdr_info = &htab->eh_info;
eh_frame_sec = bfd_get_section_by_name (abfd, ".eh_frame");
if (eh_frame_sec == NULL)
- return FALSE;
+ {
+ free (contents);
+ return FALSE;
+ }
memset (contents, 0, EH_FRAME_HDR_SIZE);
- contents[0] = 1; /* Version */
- contents[1] = DW_EH_PE_pcrel | DW_EH_PE_sdata4; /* .eh_frame offset */
+ contents[0] = 1; /* Version. */
+ contents[1] = DW_EH_PE_pcrel | DW_EH_PE_sdata4; /* .eh_frame offset. */
if (hdr_info->array && hdr_info->array_count == hdr_info->fde_count)
{
- contents[2] = DW_EH_PE_udata4; /* FDE count encoding */
- contents[3] = DW_EH_PE_datarel | DW_EH_PE_sdata4; /* search table enc */
+ contents[2] = DW_EH_PE_udata4; /* FDE count encoding. */
+ contents[3] = DW_EH_PE_datarel | DW_EH_PE_sdata4; /* Search table enc. */
}
else
{
}
}
- return bfd_set_section_contents (abfd, sec->output_section,
- contents, (file_ptr) sec->output_offset,
- sec->_cooked_size);
+ retval = bfd_set_section_contents (abfd, sec->output_section,
+ contents, (file_ptr) sec->output_offset,
+ sec->_cooked_size);
+ free (contents);
+ return retval;
}
amt += ((bfd_size_type) section_count - 1) * sizeof (asection *);
map = (struct elf_segment_map *) bfd_alloc (obfd, amt);
if (map == NULL)
- return FALSE;
+ {
+ free (sections);
+ return FALSE;
+ }
/* Initialise the fields of the segment map. Set the physical
physical address to the LMA of the first section that has
amt = (bfd_size_type) (1 + symcount) * bed->s->sizeof_sym;
outbound_syms = bfd_alloc (abfd, amt);
if (outbound_syms == NULL)
- return FALSE;
+ {
+ _bfd_stringtab_free (stt);
+ return FALSE;
+ }
symtab_hdr->contents = (PTR) outbound_syms;
outbound_shndx = NULL;
amt = (bfd_size_type) (1 + symcount) * sizeof (Elf_External_Sym_Shndx);
outbound_shndx = bfd_zalloc (abfd, amt);
if (outbound_shndx == NULL)
- return FALSE;
+ {
+ _bfd_stringtab_free (stt);
+ return FALSE;
+ }
+
symtab_shndx_hdr->contents = outbound_shndx;
symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
symtab_shndx_hdr->sh_size = amt;
syms[idx]->name,
TRUE, FALSE);
if (sym.st_name == (unsigned long) -1)
- return FALSE;
+ {
+ _bfd_stringtab_free (stt);
+ return FALSE;
+ }
}
type_ptr = elf_symbol_from (abfd, syms[idx]);
syms[idx]->name ? syms[idx]->name : "<Local sym>",
sec->name);
bfd_set_error (bfd_error_invalid_operation);
+ _bfd_stringtab_free (stt);
return FALSE;
}
return TRUE;
error_return:
- if (contents == NULL)
+ if (contents != NULL)
free (contents);
return FALSE;
}
}
}
+ free (sort);
*psec = reldyn;
return ret;
}
if (!abfd->target_defaulted)
{
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) /* rewind! */
- return FALSE;
+ {
+ if (matching)
+ free ((PTR) matching_vector);
+ return FALSE;
+ }
right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
abfd->xvec = *target; /* Change BFD's target temporarily. */
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- return FALSE;
+ {
+ if (matching)
+ free ((PTR) matching_vector);
+ return FALSE;
+ }
/* If _bfd_check_format neglects to set bfd_error, assume
bfd_error_wrong_format. We didn't used to even pay any
/* linker.c -- BFD linker routines
- Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+ Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support
-This file is part of BFD, the Binary File Descriptor library.
+ This file is part of BFD, the Binary File Descriptor library.
-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
-(at your option) any later version.
+ 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
+ (at your option) any later version.
-This program 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.
+ This program 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 this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ 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. */
#include "bfd.h"
#include "sysdep.h"
input_section,
relocs,
symbols);
+ free (relocs);
if (reloc_count < 0)
return FALSE;
BFD_ASSERT ((unsigned long) reloc_count
== input_section->reloc_count);
o->reloc_count += reloc_count;
- free (relocs);
}
}
if (o->reloc_count > 0)
basename = get_debug_link_info (abfd, & crc32);
- if (basename == NULL || strlen (basename) < 1)
+ if (basename == NULL)
return NULL;
+ if (strlen (basename) < 1)
+ {
+ free (basename);
+ return NULL;
+ }
dir = xstrdup (abfd->filename);
BFD_ASSERT (strlen (dir) != 0);
/* simple.c -- BFD simple client routines
- Copyright 2002
+ Copyright 2002, 2003
Free Software Foundation, Inc.
Contributed by MontaVista Software, Inc.
struct bfd_link_order link_order;
struct bfd_link_callbacks callbacks;
bfd_byte *contents, *data;
- int storage_needed, number_of_symbols;
+ int storage_needed;
asymbol **symbol_table;
if (! (sec->flags & SEC_RELOC))
storage_needed = bfd_get_symtab_upper_bound (abfd);
symbol_table = (asymbol **) bfd_malloc (storage_needed);
- number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
+ bfd_canonicalize_symtab (abfd, symbol_table);
contents = bfd_get_relocated_section_contents (abfd,
&link_info,
bfd_link_hash_table_free (abfd, link_info.hash);
+ free (symbol_table);
return contents;
}
+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>
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. */
|| (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;
}
{
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. */
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);
}
if (link_info.strip != strip_none)
einfo (_("%P: `-retain-symbols-file' overrides `-s' and `-S'\n"));
+ free (buf);
link_info.strip = strip_some;
}
\f
/* 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"
fprintf (fp, ":%u", linenumber);
}
+ if (asymbols != NULL && entry == NULL)
+ free (asymbols);
+
if (discard_last)
{
last_bfd = NULL;
case 'Y':
if (strncmp (optarg, "P,", 2) == 0)
optarg += 2;
+ if (default_dirlist != NULL)
+ free (default_dirlist);
default_dirlist = xstrdup (optarg);
break;
case 'y':
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