Don't lose actual error in _bfd_generic_read_minisymbols

Alan Modra amodra@gmail.com
Wed Mar 4 22:48:13 GMT 2026


Setting bfd_error_no_symbols in the error return loses the underlying
reason why the function failed.  Also fix a few places where functions
called by _bfd_generic_read_minisymbols didn't set bfd_error on failure.

	* syms.c (_bfd_generic_read_minisymbols): Don't bfd_set_error
	here.
	* aoutx.h (aout_get_external_symbols): Call bfd_set_error on
	error return.
	* pdp11.c (aout_get_external_symbols): Likewise.
	* ecoff.c (_bfd_ecoff_slurp_symbolic_info): Likewise.

diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index f081a6c5054..cb2d9270db9 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -1289,7 +1289,10 @@ static bool
 aout_get_external_symbols (bfd *abfd)
 {
   if (bfd_get_flavour (abfd) != bfd_target_aout_flavour)
-    return false;
+    {
+      bfd_set_error (bfd_error_invalid_operation);
+      return false;
+    }
 
   if (obj_aout_external_syms (abfd) == NULL)
     {
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index 7ddce8be6d2..50e42afed18 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -650,7 +650,7 @@ _bfd_ecoff_slurp_symbolic_info (bfd *abfd,
   fraw_src = (char *) debug->external_fdr;
   /* PR 17512: file: 3372-1243-0.004.  */
   if (fraw_src == NULL && internal_symhdr->ifdMax > 0)
-    return false;
+    goto err;
   fraw_end = fraw_src + internal_symhdr->ifdMax * external_fdr_size;
   for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
     (*backend->debug_swap.swap_fdr_in) (abfd, (void *) fraw_src, fdr_ptr);
diff --git a/bfd/pdp11.c b/bfd/pdp11.c
index 6472e2741f1..d1d761d9adb 100644
--- a/bfd/pdp11.c
+++ b/bfd/pdp11.c
@@ -1265,7 +1265,10 @@ static bool
 aout_get_external_symbols (bfd *abfd)
 {
   if (bfd_get_flavour (abfd) != bfd_target_aout_flavour)
-    return false;
+    {
+      bfd_set_error (bfd_error_invalid_operation);
+      return false;
+    }
 
   if (obj_aout_external_syms (abfd) == NULL)
     {
diff --git a/bfd/syms.c b/bfd/syms.c
index f990c2b3a6a..c43ee2da00e 100644
--- a/bfd/syms.c
+++ b/bfd/syms.c
@@ -858,7 +858,6 @@ _bfd_generic_read_minisymbols (bfd *abfd,
   return symcount;
 
  error_return:
-  bfd_set_error (bfd_error_no_symbols);
   free (syms);
   return -1;
 }

-- 
Alan Modra


More information about the Binutils mailing list