public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: bfd_cleanup for object_p
Date: Mon, 02 Mar 2020 13:22:00 -0000	[thread overview]
Message-ID: <20200302132223.GJ5384@bubble.grove.modra.org> (raw)
In-Reply-To: <CAMe9rOp78oL2X3eFi+fQBFodxP-yRa3MYZiX5xjxxXUE2PBD5Q@mail.gmail.com>

On Mon, Mar 02, 2020 at 04:37:30AM -0800, H.J. Lu wrote:
> 	* trad-core.c (trad_unix_core_file_p): Return bfd_cleanup.

Thanks, I missed some others too.

	* aix386-core.c (aix386_core_file_p): Return bfd_cleanup.
	* aix5ppc-core.c (xcoff64_core_p): Likewise.
	* cisco-core.c (cisco_core_file_validate): Likewise.
	* hppabsd-core.c (hppabsd_core_core_file_p): Likewise.
	* hpux-core.c (hpux_core_core_file_p): Likewise.
	* irix-core.c (irix_core_core_file_p): Likewise.
	* lynx-core.c (lynx_core_file_p): Likewise.
	* netbsd-core.c (netbsd_core_file_p): Likewise.
	* osf-core.c (osf_core_core_file_p): Likewise.
	* ptrace-core.c (ptrace_unix_core_file_p): Likewise.
	* sco5-core.c (sco5_core_file_p): Likewise.

diff --git a/bfd/aix386-core.c b/bfd/aix386-core.c
index c9ec756c4a..287ad04235 100644
--- a/bfd/aix386-core.c
+++ b/bfd/aix386-core.c
@@ -65,7 +65,7 @@ struct trad_core_struct
   asection *sections[MAX_CORE_SEGS];
 };
 
-static const bfd_target *
+static bfd_cleanup
 aix386_core_file_p (bfd *abfd)
 {
   int i, n;
@@ -189,7 +189,7 @@ aix386_core_file_p (bfd *abfd)
       n++;
     }
 
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 }
 
 static char *
diff --git a/bfd/aix5ppc-core.c b/bfd/aix5ppc-core.c
index 806d2ec02b..cddb647de1 100644
--- a/bfd/aix5ppc-core.c
+++ b/bfd/aix5ppc-core.c
@@ -23,7 +23,7 @@
 #include "sysdep.h"
 #include "bfd.h"
 
-const bfd_target *xcoff64_core_p (bfd *);
+bfd_cleanup xcoff64_core_p (bfd *);
 bfd_boolean xcoff64_core_file_matches_executable_p (bfd *, bfd *);
 char *xcoff64_core_file_failing_command (bfd *);
 int xcoff64_core_file_failing_signal (bfd *);
@@ -48,7 +48,7 @@ int xcoff64_core_file_failing_signal (bfd *);
 #define CHECK_FILE_OFFSET(s, v) \
   ((bfd_signed_vma)(v) < 0 || (bfd_signed_vma)(v) > (bfd_signed_vma)(s).st_size)
 
-const bfd_target *
+bfd_cleanup
 xcoff64_core_p (bfd *abfd)
 {
   enum bfd_architecture arch;
@@ -60,7 +60,6 @@ xcoff64_core_p (bfd *abfd)
   bfd_vma ld_offset;
   bfd_size_type i;
   struct vm_infox vminfo;
-  const bfd_target *return_value = NULL;
   flagword flags;
 
   /* Get the header.  */
@@ -109,12 +108,12 @@ xcoff64_core_p (bfd *abfd)
     {
       bfd_set_error (bfd_error_file_truncated);
 
-      return return_value;
+      return NULL;
     }
 
   new_core_hdr = bfd_zalloc (abfd, sizeof (struct core_dumpxx));
   if (NULL == new_core_hdr)
-    return return_value;
+    return NULL;
 
   memcpy (new_core_hdr, &core, sizeof (struct core_dumpxx));
   /* The core_hdr() macro is no longer used here because it would
@@ -126,7 +125,7 @@ xcoff64_core_p (bfd *abfd)
   flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   sec = bfd_make_section_anyway_with_flags (abfd, ".stack", flags);
   if (NULL == sec)
-    return return_value;
+    return NULL;
 
   sec->size = core.c_size;
   sec->vma = core.c_stackorg;
@@ -136,7 +135,7 @@ xcoff64_core_p (bfd *abfd)
   flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
   sec = bfd_make_section_anyway_with_flags (abfd, ".reg", flags);
   if (NULL == sec)
-    return return_value;
+    return NULL;
 
   sec->size = sizeof (struct __context64);
   sec->vma = 0;
@@ -150,7 +149,7 @@ xcoff64_core_p (bfd *abfd)
   flags = SEC_HAS_CONTENTS;
   sec = bfd_make_section_anyway_with_flags (abfd, ".ldinfo", flags);
   if (NULL == sec)
-    return return_value;
+    return NULL;
 
   sec->size = core.c_lsize;
   sec->vma = 0;
@@ -164,7 +163,7 @@ xcoff64_core_p (bfd *abfd)
   flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   sec = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
   if (NULL == sec)
-    return return_value;
+    return NULL;
 
   sec->size = core.c_datasize;
   sec->vma = core.c_dataorg;
@@ -176,18 +175,18 @@ xcoff64_core_p (bfd *abfd)
   while (1)
     {
       if (bfd_seek (abfd, ld_offset, SEEK_SET) != 0)
-	return return_value;
+	return NULL;
 
       if (sizeof (struct __ld_info64) !=
 	  bfd_bread (&ldinfo, sizeof (struct __ld_info64), abfd))
-	return return_value;
+	return NULL;
 
       if (ldinfo.ldinfo_core)
 	{
 	  flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
 	  sec = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
 	  if (NULL == sec)
-	    return return_value;
+	    return NULL;
 
 	  sec->size = ldinfo.ldinfo_datasize;
 	  sec->vma = ldinfo.ldinfo_dataorg;
@@ -203,19 +202,19 @@ xcoff64_core_p (bfd *abfd)
   if (core.c_vmregions)
     {
       if (bfd_seek (abfd, core.c_vmm, SEEK_SET) != 0)
-	return return_value;
+	return NULL;
 
       for (i = 0; i < core.c_vmregions; i++)
 	if (sizeof (struct vm_infox) !=
 	    bfd_bread (&vminfo, sizeof (struct vm_infox), abfd))
-	  return return_value;
+	  return NULL;
 
       if (vminfo.vminfo_offset)
 	{
 	  flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
 	  sec = bfd_make_section_anyway_with_flags (abfd, ".vmdata", flags);
 	  if (NULL == sec)
-	    return return_value;
+	    return NULL;
 
 	  sec->size = vminfo.vminfo_size;
 	  sec->vma = vminfo.vminfo_addr;
@@ -228,13 +227,13 @@ xcoff64_core_p (bfd *abfd)
   mach = DEFAULT_MACHINE;
   bfd_default_set_arch_mach (abfd, arch, mach);
 
-  return_value = (bfd_target *) abfd->xvec;	/* This is garbage for now.  */
+  return _bfd_no_cleanup;
 
  xcoff64_core_p_error:
   if (bfd_get_error () != bfd_error_system_call)
     bfd_set_error (bfd_error_wrong_format);
 
-  return return_value;
+  return NULL;
 }
 
 /* Return `TRUE' if given core is from the given executable.  */
@@ -329,7 +328,7 @@ xcoff64_core_file_failing_signal (bfd *abfd)
 
 #else /* AIX_5_CORE */
 
-const bfd_target *
+bfd_cleanup
 xcoff64_core_p (bfd *abfd ATTRIBUTE_UNUSED)
 {
   bfd_set_error (bfd_error_wrong_format);
diff --git a/bfd/cisco-core.c b/bfd/cisco-core.c
index da18d2edbf..e43982bf08 100644
--- a/bfd/cisco-core.c
+++ b/bfd/cisco-core.c
@@ -80,7 +80,7 @@ struct cisco_core_struct
 /* Examine the file for a crash info struct at the offset given by
    CRASH_INFO_LOC.  */
 
-static const bfd_target *
+static bfd_cleanup
 cisco_core_file_validate (bfd *abfd, int crash_info_loc)
 {
   char buf[4];
@@ -274,7 +274,7 @@ cisco_core_file_validate (bfd *abfd, int crash_info_loc)
   nread = statbuf.st_size - asect->filepos;
   asect->size = (nread < 1024) ? nread : 1024;
 
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 
   /* Get here if we have already started filling out the BFD
      and there is an error of some kind.  */
diff --git a/bfd/hppabsd-core.c b/bfd/hppabsd-core.c
index 347771c624..e0f2b50037 100644
--- a/bfd/hppabsd-core.c
+++ b/bfd/hppabsd-core.c
@@ -90,7 +90,7 @@ make_bfd_asection (bfd *abfd,
   return asect;
 }
 
-static const bfd_target *
+static bfd_cleanup
 hppabsd_core_core_file_p (bfd *abfd)
 {
   int val;
@@ -181,7 +181,7 @@ hppabsd_core_core_file_p (bfd *abfd)
 
   strncpy (core_command (abfd), u.u_comm, MAXCOMLEN + 1);
   core_signal (abfd) = u.u_code;
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 
  fail:
   bfd_release (abfd, abfd->tdata.any);
diff --git a/bfd/hpux-core.c b/bfd/hpux-core.c
index 36a17dc9d9..2b4de9e530 100644
--- a/bfd/hpux-core.c
+++ b/bfd/hpux-core.c
@@ -157,7 +157,7 @@ thread_section_p (bfd *abfd ATTRIBUTE_UNUSED,
    in which the core file is generated by some non-hpux application.
    (I am just guessing here!)
 */
-static const bfd_target *
+static bfd_cleanup
 hpux_core_core_file_p (bfd *abfd)
 {
   int  good_sections = 0;
@@ -342,7 +342,7 @@ hpux_core_core_file_p (bfd *abfd)
        "  As a result, some information may be unavailable.\n",
        abfd);
 
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 
  fail:
   bfd_release (abfd, core_hdr (abfd));
diff --git a/bfd/irix-core.c b/bfd/irix-core.c
index 7b214e0a0a..a63d4104d4 100644
--- a/bfd/irix-core.c
+++ b/bfd/irix-core.c
@@ -166,7 +166,7 @@ make_bfd_asection (bfd *abfd,
   return asect;
 }
 
-static const bfd_target *
+static bfd_cleanup
 irix_core_core_file_p (bfd *abfd)
 {
   int val;
@@ -244,7 +244,7 @@ irix_core_core_file_p (bfd *abfd)
   /* OK, we believe you.  You're a core file (sure, sure).  */
   bfd_default_set_arch_mach (abfd, bfd_arch_mips, 0);
 
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 
  fail:
   bfd_release (abfd, core_hdr (abfd));
diff --git a/bfd/lynx-core.c b/bfd/lynx-core.c
index 66b54a2fd2..08d0883861 100644
--- a/bfd/lynx-core.c
+++ b/bfd/lynx-core.c
@@ -85,7 +85,7 @@ make_bfd_asection (bfd *abfd,
   return asect;
 }
 
-const bfd_target *
+bfd_cleanup
 lynx_core_file_p (bfd *abfd)
 {
   int secnum;
@@ -191,7 +191,7 @@ lynx_core_file_p (bfd *abfd)
 	goto fail;
     }
 
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 
  fail:
   bfd_release (abfd, core_hdr (abfd));
diff --git a/bfd/netbsd-core.c b/bfd/netbsd-core.c
index ae88fd6f74..83ad33060f 100644
--- a/bfd/netbsd-core.c
+++ b/bfd/netbsd-core.c
@@ -51,7 +51,7 @@ struct netbsd_core_struct
 
 /* Handle NetBSD-style core dump file.  */
 
-static const bfd_target *
+static bfd_cleanup
 netbsd_core_file_p (bfd *abfd)
 {
   int val;
@@ -222,7 +222,7 @@ netbsd_core_file_p (bfd *abfd)
     }
 
   /* OK, we believe you.  You're a core file (sure, sure).  */
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 
  punt:
   bfd_release (abfd, abfd->tdata.any);
diff --git a/bfd/osf-core.c b/bfd/osf-core.c
index 19cd4f2b75..3f384e7bd4 100644
--- a/bfd/osf-core.c
+++ b/bfd/osf-core.c
@@ -70,7 +70,7 @@ make_bfd_asection (bfd *abfd,
   return asect;
 }
 
-static const bfd_target *
+static bfd_cleanup
 osf_core_core_file_p (bfd *abfd)
 {
   int val;
@@ -138,7 +138,7 @@ osf_core_core_file_p (bfd *abfd)
 
   /* OK, we believe you.  You're a core file (sure, sure).  */
 
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 
  fail:
   bfd_release (abfd, core_hdr (abfd));
diff --git a/bfd/ptrace-core.c b/bfd/ptrace-core.c
index 48a9b1c669..e9802f8ea0 100644
--- a/bfd/ptrace-core.c
+++ b/bfd/ptrace-core.c
@@ -55,7 +55,7 @@ int ptrace_unix_core_file_failing_signal (bfd *abfd);
 #define ptrace_unix_core_file_pid _bfd_nocore_core_file_pid
 static void swap_abort (void);
 
-const bfd_target *
+bfd_cleanup
 ptrace_unix_core_file_p (bfd *abfd)
 {
   int val;
@@ -124,7 +124,7 @@ ptrace_unix_core_file_p (bfd *abfd)
   core_datasec (abfd)->alignment_power = 2;
   core_regsec (abfd)->alignment_power = 2;
 
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 
  fail:
   bfd_release (abfd, abfd->tdata.any);
diff --git a/bfd/sco5-core.c b/bfd/sco5-core.c
index a9afbbacd9..84dbf4f27f 100644
--- a/bfd/sco5-core.c
+++ b/bfd/sco5-core.c
@@ -101,7 +101,7 @@ read_uarea (bfd *abfd, int filepos)
   return &rawptr->u;
 }
 
-const bfd_target *
+const bfd_cleanup
 sco5_core_file_p (bfd *abfd)
 {
   int coffset_siz, val, nsecs, cheadoffs;
@@ -300,7 +300,7 @@ sco5_core_file_p (bfd *abfd)
 
     }
 
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 
  fail:
   if (abfd->tdata.any)

-- 
Alan Modra
Australia Development Lab, IBM

  reply	other threads:[~2020-03-02 13:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02  8:59 Alan Modra
2020-03-02 12:38 ` H.J. Lu
2020-03-02 13:22   ` Alan Modra [this message]
2020-03-02 13:46     ` Alan Modra
2020-03-03 11:14 ` bfd_check_format_matches preserving matches vs. cleanups Alan Modra
2022-09-24  2:05 bfd_cleanup for object_p Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200302132223.GJ5384@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).