From 90d92a632aaf75ce698335efeb383ddf785c12d8 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 18 Sep 2019 10:34:46 +0930 Subject: Use bfd_set_filename more Fixes a few leaks in bfd and ld. bfd/ * mach-o.c (bfd_mach_o_fat_member_init): Likewise. Replace xstrdup and xmalloc with bfd_strdup and bfd_malloc. Return an error status. Adjust calls. * vms-lib.c (_bfd_vms_lib_get_module): Test mhd->id earlier. Close bfd on failure. Replace xstrdup/bfd_alloc use with bfd_malloc. Use bfd_set_filename. gdb/ * solib-spu.c (spu_bfd_open): Use bfd_set_filename. * spu-linux-nat.c (spu_bfd_open): Likewise. ld/ * emultempl/pe.em (after_open): Use bfd_set_filename. * emultempl/pep.em (after_open): Use bfd_set_filename. --- ld/ChangeLog | 5 +++++ ld/emultempl/pe.em | 4 ++-- ld/emultempl/pep.em | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index ea28a0b..81935a4 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2019-09-18 Alan Modra + + * emultempl/pe.em (after_open): Use bfd_set_filename. + * emultempl/pep.em (after_open): Use bfd_set_filename. + 2019-09-16 Alan Modra PR 25002 diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 49bb66b..2e78f26 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -1543,7 +1543,7 @@ gld_${EMULATION_NAME}_after_open (void) /* Rename this implib to match the other one. */ n = xmalloc (strlen (other_bfd_filename) + 1); strcpy (n, other_bfd_filename); - is->the_bfd->my_archive->filename = n; + bfd_set_filename (is->the_bfd->my_archive, n); } free (relocs); @@ -1648,7 +1648,7 @@ gld_${EMULATION_NAME}_after_open (void) new_name = xmalloc (strlen (is->the_bfd->filename) + 3); sprintf (new_name, "%s.%c", is->the_bfd->filename, seq); - is->the_bfd->filename = new_name; + bfd_set_filename (is->the_bfd, new_name); new_name = xmalloc (strlen (is->filename) + 3); sprintf (new_name, "%s.%c", is->filename, seq); diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index 4daa32b..601ef11 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -1510,7 +1510,7 @@ gld_${EMULATION_NAME}_after_open (void) /* Rename this implib to match the other one. */ n = xmalloc (strlen (other_bfd_filename) + 1); strcpy (n, other_bfd_filename); - is->the_bfd->my_archive->filename = n; + bfd_set_filename (is->the_bfd->my_archive, n); } free (relocs); @@ -1615,7 +1615,7 @@ gld_${EMULATION_NAME}_after_open (void) new_name = xmalloc (strlen (is->the_bfd->filename) + 3); sprintf (new_name, "%s.%c", is->the_bfd->filename, seq); - is->the_bfd->filename = new_name; + bfd_set_filename (is->the_bfd, new_name); new_name = xmalloc (strlen (is->filename) + 3); sprintf (new_name, "%s.%c", is->filename, seq); -- cgit v1.1