Format elf_link_read_relocs calls

Message ID auJ4lWhjjOAYIX7u@squeak.grove.modra.org
State New
Headers
Series Format elf_link_read_relocs calls |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Alan Modra Oct. 28, 2026, 10:35 p.m. UTC
  At one point I was going to add another parameter to these calls but
backed that change out.  All that is left here is formatting,
removing some unnecessary casts of NULL, and removing some comments.
  

Patch

diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c
index 22a165873c3..2b2cc3a442c 100644
--- a/bfd/elf-m10200.c
+++ b/bfd/elf-m10200.c
@@ -587,9 +587,8 @@  mn10200_elf_relax_section (bfd *abfd,
   symtab_hdr = &elf_symtab_hdr (abfd);
 
   /* Get a copy of the native relocations.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
-		      link_info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
 
@@ -1310,9 +1309,8 @@  mn10200_elf_get_relocated_section_contents
       asection **secpp;
       bfd_size_type amt;
 
-      internal_relocs = (_bfd_elf_link_read_relocs
-			 (input_bfd, input_section, NULL,
-			  (Elf_Internal_Rela *) NULL, false));
+      internal_relocs = _bfd_elf_link_read_relocs (input_bfd, input_section,
+						   NULL, NULL, false);
       if (internal_relocs == NULL)
 	goto error_return;
 
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index 332b294e1e2..808fd9ac58e 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -2715,9 +2715,9 @@  mn10300_elf_relax_section (bfd *abfd,
 		  && section->reloc_count != 0)
 		{
 		  /* Get a copy of the native relocations.  */
-		  internal_relocs = _bfd_elf_link_read_relocs (input_bfd, section,
-							       NULL, NULL,
-							       link_info->keep_memory);
+		  internal_relocs
+		    = _bfd_elf_link_read_relocs (input_bfd, section, NULL, NULL,
+						 link_info->keep_memory);
 		  if (internal_relocs == NULL)
 		    goto error_return;
 
@@ -3042,9 +3042,9 @@  mn10300_elf_relax_section (bfd *abfd,
 	      if (section->reloc_count != 0)
 		{
 		  /* Get a copy of the native relocations.  */
-		  internal_relocs = _bfd_elf_link_read_relocs (input_bfd, section,
-							       NULL, NULL,
-							       link_info->keep_memory);
+		  internal_relocs
+		    = _bfd_elf_link_read_relocs (input_bfd, section, NULL, NULL,
+						 link_info->keep_memory);
 		  if (internal_relocs == NULL)
 		    goto error_return;
 		}
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index fc58da0efa7..ad58553c44f 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -3003,7 +3003,7 @@  arc_elf_relax_section (bfd *abfd, asection *sec,
 
   /* Get a copy of the native relocations.  */
   internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
-                                               link_info->keep_memory);
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
 
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index f8a20e49ce8..17963aa9cce 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -6470,8 +6470,8 @@  elf32_arm_size_stubs (bfd *output_bfd,
 
 	      /* Get the relocs.  */
 	      internal_relocs
-		= _bfd_elf_link_read_relocs (input_bfd, section, NULL,
-					     NULL, info->keep_memory);
+		= _bfd_elf_link_read_relocs (input_bfd, section, NULL, NULL,
+					     info->keep_memory);
 	      if (internal_relocs == NULL)
 		goto error_ret_free_local;
 
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 082b86a307d..1e11e3f0d95 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -4398,8 +4398,7 @@  avr_elf32_load_records_from_section (bfd *abfd, asection *sec)
 
   /* Load the relocations for the '.avr.prop' section if there are any, and
      sort them.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, NULL, false));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, false);
   if (internal_relocs)
     qsort (internal_relocs, sec->reloc_count,
 	   sizeof (Elf_Internal_Rela), internal_reloc_compare);
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index af8826a811f..f57519e7392 100644
--- a/bfd/elf32-bfin.c
+++ b/bfd/elf32-bfin.c
@@ -5302,9 +5302,8 @@  bfd_bfin_elf32_create_embedded_relocs (bfd *abfd,
   symtab_hdr = &elf_symtab_hdr (abfd);
 
   /* Get a copy of the native relocations.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, datasec, NULL, (Elf_Internal_Rela *) NULL,
-		      info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, datasec, NULL, NULL,
+					       info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
 
diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c
index 23365147b41..a8a5112de69 100644
--- a/bfd/elf32-cr16.c
+++ b/bfd/elf32-cr16.c
@@ -2682,8 +2682,8 @@  bfd_cr16_elf32_create_embedded_relocs (bfd *abfd,
   symtab_hdr = &elf_symtab_hdr (abfd);
 
   /* Get a copy of the native relocations.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, datasec, NULL, NULL, info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, datasec, NULL, NULL,
+					       info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
 
diff --git a/bfd/elf32-crx.c b/bfd/elf32-crx.c
index 16abc3814c0..ca7413592ef 100644
--- a/bfd/elf32-crx.c
+++ b/bfd/elf32-crx.c
@@ -761,9 +761,8 @@  elf32_crx_get_relocated_section_contents
       asection **secpp;
       bfd_size_type amt;
 
-      internal_relocs = (_bfd_elf_link_read_relocs
-			 (input_bfd, input_section, NULL,
-			  (Elf_Internal_Rela *) NULL, false));
+      internal_relocs = _bfd_elf_link_read_relocs (input_bfd, input_section,
+						   NULL, NULL, false);
       if (internal_relocs == NULL)
 	goto error_return;
 
@@ -985,9 +984,8 @@  elf32_crx_relax_section (bfd *abfd, asection *sec,
   symtab_hdr = &elf_symtab_hdr (abfd);
 
   /* Get a copy of the native relocations.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
-		      link_info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
 
diff --git a/bfd/elf32-csky.c b/bfd/elf32-csky.c
index 239662e0748..4eb6524de5e 100644
--- a/bfd/elf32-csky.c
+++ b/bfd/elf32-csky.c
@@ -3475,10 +3475,9 @@  elf32_csky_size_stubs (bfd *output_bfd,
 		continue;
 
 	      /* Get the relocs.  */
-	      internal_relocs = _bfd_elf_link_read_relocs (input_bfd,
-							   section,
-							   NULL, NULL,
-							   info->keep_memory);
+	      internal_relocs
+		= _bfd_elf_link_read_relocs (input_bfd, section, NULL, NULL,
+					     info->keep_memory);
 
 	      if (internal_relocs == NULL)
 		goto error_ret_free_local;
diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c
index f9550c6f694..abafaa531df 100644
--- a/bfd/elf32-h8300.c
+++ b/bfd/elf32-h8300.c
@@ -712,9 +712,8 @@  elf32_h8_relax_section (bfd *abfd, asection *sec,
   symtab_hdr = &elf_symtab_hdr (abfd);
 
   /* Get a copy of the native relocations.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
-		      link_info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
 
@@ -1639,9 +1638,8 @@  elf32_h8_get_relocated_section_contents
       Elf_Internal_Sym *isym, *isymend;
       bfd_size_type amt;
 
-      internal_relocs = (_bfd_elf_link_read_relocs
-			 (input_bfd, input_section, NULL,
-			  (Elf_Internal_Rela *) NULL, false));
+      internal_relocs = _bfd_elf_link_read_relocs (input_bfd, input_section,
+						   NULL, NULL, false);
       if (internal_relocs == NULL)
 	goto error_return;
 
diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c
index e9fbb1a131e..8873a25aecc 100644
--- a/bfd/elf32-lm32.c
+++ b/bfd/elf32-lm32.c
@@ -2102,7 +2102,8 @@  lm32_elf_late_size_sections (struct bfd_link_info *info)
 		  Elf_Internal_Rela *internal_relocs, *end;
 		  internal_relocs = elf_section_data (s)->relocs;
 		  if (internal_relocs == NULL)
-		    internal_relocs = (_bfd_elf_link_read_relocs (ibfd, s, NULL, NULL, false));
+		    internal_relocs
+		      = _bfd_elf_link_read_relocs (ibfd, s, NULL, NULL, false);
 		  if (internal_relocs != NULL)
 		    {
 		      end = internal_relocs + s->reloc_count;
diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c
index fbe9eb2978a..3589ffe4608 100644
--- a/bfd/elf32-m32c.c
+++ b/bfd/elf32-m32c.c
@@ -1512,9 +1512,8 @@  m32c_elf_relax_section (bfd *abfd,
     }
 
   /* Get a copy of the native relocations.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
-		      link_info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
   if (! link_info->keep_memory)
diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c
index 8465264c9e5..483788be873 100644
--- a/bfd/elf32-m68hc11.c
+++ b/bfd/elf32-m68hc11.c
@@ -718,9 +718,8 @@  m68hc11_elf_relax_section (bfd *abfd, asection *sec,
   symtab_hdr = &elf_symtab_hdr (abfd);
 
   /* Get a copy of the native relocations.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
-		      link_info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
   if (! link_info->keep_memory)
diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c
index dd8b24aa504..02c998a6f5c 100644
--- a/bfd/elf32-m68hc1x.c
+++ b/bfd/elf32-m68hc1x.c
@@ -425,8 +425,7 @@  elf32_m68hc11_size_stubs (bfd *output_bfd, bfd *stub_bfd,
 
 	  /* Get the relocs.  */
 	  internal_relocs
-	    = _bfd_elf_link_read_relocs (input_bfd, section, NULL,
-					 (Elf_Internal_Rela *) NULL,
+	    = _bfd_elf_link_read_relocs (input_bfd, section, NULL, NULL,
 					 info->keep_memory);
 	  if (internal_relocs == NULL)
 	    goto error_ret_free_local;
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index f1027df4b48..cc05d0eb01b 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -4391,9 +4391,8 @@  bfd_m68k_elf32_create_embedded_relocs (bfd *abfd, struct bfd_link_info *info,
   symtab_hdr = &elf_symtab_hdr (abfd);
 
   /* Get a copy of the native relocations.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, datasec, NULL, (Elf_Internal_Rela *) NULL,
-		      info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, datasec, NULL, NULL,
+					       info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
 
diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index b67c4be414e..14172094c3e 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -1906,7 +1906,8 @@  microblaze_elf_relax_section (bfd *abfd,
 	goto error_return;
     }
 
-  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, link_info->keep_memory);
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
   if (! link_info->keep_memory)
diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c
index adba0e25f1b..6948fd3a1f1 100644
--- a/bfd/elf32-msp430.c
+++ b/bfd/elf32-msp430.c
@@ -1990,8 +1990,8 @@  msp430_elf_relax_section (bfd * abfd, asection * sec,
   symtab_hdr = &elf_symtab_hdr (abfd);
 
   /* Get a copy of the native relocations.  */
-  internal_relocs =
-    _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, link_info->keep_memory);
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
 
diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c
index cde22dc2a9b..1c1cb4ca030 100644
--- a/bfd/elf32-nds32.c
+++ b/bfd/elf32-nds32.c
@@ -9320,7 +9320,7 @@  nds32_elf_relax_delete_blanks (bfd *abfd, asection *sec,
 
       /* Relocations MUST be kept in memory, because relaxation adjust them.  */
       internal_relocs = _bfd_elf_link_read_relocs (abfd, sect, NULL, NULL,
-						   true /* keep_memory */);
+						   true);
       irelend = internal_relocs + sect->reloc_count;
 
       blank_t = blank_head;
@@ -12260,7 +12260,7 @@  nds32_elf_relax_section (bfd *abfd, asection *sec,
   symtab_hdr = &elf_symtab_hdr (abfd);
   /* Relocations MUST be kept in memory, because relaxation adjust them.  */
   internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
-					       true /* keep_memory */);
+					       true);
   if (internal_relocs == NULL)
     goto error_return;
 
@@ -13399,8 +13399,7 @@  elf32_nds32_check_relax_group (bfd *abfd, asection *asec)
   do
     {
       /* Relocations MUST be kept in memory, because relaxation adjust them.  */
-      relocs = _bfd_elf_link_read_relocs (abfd, asec, NULL, NULL,
-					  true /* keep_memory  */);
+      relocs = _bfd_elf_link_read_relocs (abfd, asec, NULL, NULL, true);
       if (relocs == NULL)
 	break;
 
@@ -13528,8 +13527,7 @@  elf32_nds32_unify_relax_group (bfd *abfd, asection *asec)
 	break; /* Hit, the section id has handled.  */
 
       /* Relocations MUST be kept in memory, because relaxation adjust them.  */
-      relocs = _bfd_elf_link_read_relocs (abfd, asec, NULL, NULL,
-					  true /* keep_memory  */);
+      relocs = _bfd_elf_link_read_relocs (abfd, asec, NULL, NULL, true);
       if (relocs == NULL)
 	{
 	  BFD_ASSERT (0); /* feed me */
@@ -13592,8 +13590,7 @@  nds32_elf_unify_tls_model (bfd *inbfd, asection *insec, bfd_byte *incontents,
     }
 
   /* Relocations MUST be kept in memory, because relaxation adjust them.  */
-  internal_relocs = _bfd_elf_link_read_relocs (inbfd, insec, NULL, NULL,
-					       true /* keep_memory  */);
+  internal_relocs = _bfd_elf_link_read_relocs (inbfd, insec, NULL, NULL, true);
   if (internal_relocs == NULL)
     goto error_return;
 
diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c
index 37db811255e..68b1528d73e 100644
--- a/bfd/elf32-rl78.c
+++ b/bfd/elf32-rl78.c
@@ -2172,9 +2172,8 @@  rl78_elf_relax_section (bfd *abfd,
     }
 
   /* Get a copy of the native relocations.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
-		      link_info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
   if (! link_info->keep_memory)
diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c
index e100b3cd0ea..c3c4bd90cfa 100644
--- a/bfd/elf32-rx.c
+++ b/bfd/elf32-rx.c
@@ -2139,8 +2139,7 @@  elf32_rx_relax_section (bfd *abfd,
      because we are going to walk over them multiple times, adjusting them
      as bytes are deleted from the section, and with this relaxation
      function itself being called multiple times on the same section...  */
-  internal_relocs = _bfd_elf_link_read_relocs
-    (abfd, sec, NULL, (Elf_Internal_Rela *) NULL, true);
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, true);
   if (internal_relocs == NULL)
     goto error_return;
 
diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c
index 2f4b790d1ca..4ceb15f006c 100644
--- a/bfd/elf32-score.c
+++ b/bfd/elf32-score.c
@@ -3847,7 +3847,8 @@  s3_bfd_score_elf_discard_info (bfd *abfd, struct elf_reloc_cookie *cookie,
   if (!tdata)
     return false;
 
-  cookie->rels = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, info->keep_memory);
+  cookie->rels = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL,
+					    info->keep_memory);
   if (!cookie->rels)
     {
       free (tdata);
diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c
index bd3eb40dcd9..46244e6f45e 100644
--- a/bfd/elf32-score7.c
+++ b/bfd/elf32-score7.c
@@ -3658,7 +3658,8 @@  s7_bfd_score_elf_discard_info (bfd *abfd,
   if (!tdata)
     return false;
 
-  cookie->rels = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, info->keep_memory);
+  cookie->rels = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL,
+					    info->keep_memory);
   if (!cookie->rels)
     {
       free (tdata);
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index a78a9c38d15..684613f4356 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -475,9 +475,8 @@  sh_elf_relax_section (bfd *abfd, asection *sec,
 
   symtab_hdr = &elf_symtab_hdr (abfd);
 
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
-		      link_info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
 
@@ -1163,8 +1162,7 @@  sh_elf_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr,
       /* We always cache the relocs.  Perhaps, if info->keep_memory is
 	 FALSE, we should free them, if we are permitted to, when we
 	 leave sh_coff_relax_section.  */
-      internal_relocs = (_bfd_elf_link_read_relocs
-			 (abfd, o, NULL, (Elf_Internal_Rela *) NULL, true));
+      internal_relocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, true);
       if (internal_relocs == NULL)
 	return false;
 
@@ -5102,9 +5100,8 @@  sh_elf_get_relocated_section_contents (bfd *output_bfd,
       Elf_Internal_Sym *isym, *isymend;
       bfd_size_type amt;
 
-      internal_relocs = (_bfd_elf_link_read_relocs
-			 (input_bfd, input_section, NULL,
-			  (Elf_Internal_Rela *) NULL, false));
+      internal_relocs = _bfd_elf_link_read_relocs (input_bfd, input_section,
+						   NULL, NULL, false);
       if (internal_relocs == NULL)
 	goto error_return;
 
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
index 6956fa8c499..fe994877e6b 100644
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -3452,8 +3452,8 @@  v850_elf_relax_section (bfd *abfd,
 
   symtab_hdr = &elf_symtab_hdr (abfd);
 
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, NULL, link_info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
 
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 847c57bcd25..709f81e5bda 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -6910,8 +6910,8 @@  retrieve_internal_relocs (bfd *abfd, asection *sec, bool keep_memory)
 
   internal_relocs = elf_section_data (sec)->relocs;
   if (internal_relocs == NULL)
-    internal_relocs = (_bfd_elf_link_read_relocs
-		       (abfd, sec, NULL, NULL, keep_memory));
+    internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+						 keep_memory);
   return internal_relocs;
 }
 
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index e542d0bc88b..559445ba0e9 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -3462,10 +3462,9 @@  elf64_alpha_relax_opt_call (struct alpha_relax_info *info, bfd_vma symval)
 	}
       else
 	{
-	  tsec_relocs = (_bfd_elf_link_read_relocs
-			 (info->abfd, info->tsec, NULL,
-			 (Elf_Internal_Rela *) NULL,
-			 info->link_info->keep_memory));
+	  tsec_relocs
+	    = _bfd_elf_link_read_relocs (info->abfd, info->tsec, NULL, NULL,
+					 info->link_info->keep_memory);
 	  if (tsec_relocs == NULL)
 	    return 0;
 	  tsec_relend = tsec_relocs + info->tsec->reloc_count;
@@ -4083,9 +4082,9 @@  elf64_alpha_relax_section (bfd *abfd, asection *sec,
   local_got_entries = alpha_elf_tdata(abfd)->local_got_entries;
 
   /* Load the relocations for this section.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
-		      link_info->keep_memory));
+  internal_relocs
+    = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+				 link_info->keep_memory);
   if (internal_relocs == NULL)
     return false;
 
diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c
index 6a80caf06c0..e89ec920492 100644
--- a/bfd/elf64-ia64-vms.c
+++ b/bfd/elf64-ia64-vms.c
@@ -384,9 +384,8 @@  elf64_ia64_relax_section (bfd *abfd, asection *sec,
   symtab_hdr = &elf_symtab_hdr (abfd);
 
   /* Load the relocations for this section.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
-		      link_info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     return false;
 
diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c
index 0c21f14588b..c4fc507ba24 100644
--- a/bfd/elf64-mmix.c
+++ b/bfd/elf64-mmix.c
@@ -2023,10 +2023,8 @@  _bfd_mmix_check_all_relocs (bfd *abfd, struct bfd_link_info *info)
 	  || bfd_is_abs_section (o->output_section))
 	continue;
 
-      internal_relocs
-	= _bfd_elf_link_read_relocs (abfd, o, NULL,
-				     (Elf_Internal_Rela *) NULL,
-				     info->keep_memory);
+      internal_relocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL,
+						   info->keep_memory);
       if (internal_relocs == NULL)
 	return false;
 
@@ -2556,10 +2554,8 @@  mmix_elf_relax_section (bfd *abfd,
     gregdata = NULL;
 
   /* Get a copy of the native relocations.  */
-  internal_relocs
-    = _bfd_elf_link_read_relocs (abfd, sec, NULL,
-				 (Elf_Internal_Rela *) NULL,
-				 link_info->keep_memory);
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
 
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 0506a44f521..1eef868be49 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -4358,9 +4358,9 @@  _bfd_elf_link_iterate_on_relocs
 	      || bfd_is_abs_section (o->output_section))
 	    continue;
 
-	  internal_relocs = _bfd_elf_link_info_read_relocs
-	    (abfd, info, o, NULL, NULL,
-	     _bfd_elf_link_keep_memory (info));
+	  internal_relocs
+	    = _bfd_elf_link_info_read_relocs (abfd, info, o, NULL, NULL,
+					      _bfd_elf_link_keep_memory (info));
 	  if (internal_relocs == NULL)
 	    return false;
 
@@ -5841,9 +5841,9 @@  elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 	      || (s->flags & SEC_DEBUGGING) != 0)
 	    continue;
 
-	  internal_relocs = _bfd_elf_link_info_read_relocs
-	    (abfd, info, s, NULL, NULL,
-	     _bfd_elf_link_keep_memory (info));
+	  internal_relocs
+	    = _bfd_elf_link_info_read_relocs (abfd, info, s, NULL, NULL,
+					      _bfd_elf_link_keep_memory (info));
 	  if (internal_relocs == NULL)
 	    goto error_free_vers;
 
@@ -13972,9 +13972,10 @@  init_reloc_cookie_rels (struct elf_reloc_cookie *cookie,
     }
   else
     {
-      cookie->rels = _bfd_elf_link_info_read_relocs
-	(abfd, info, sec, NULL, NULL,
-	 keep_memory || _bfd_elf_link_keep_memory (info));
+      keep_memory = keep_memory || _bfd_elf_link_keep_memory (info);
+      cookie->rels
+	= _bfd_elf_link_info_read_relocs (abfd, info, sec, NULL, NULL,
+					  keep_memory);
       if (cookie->rels == NULL)
 	return false;
       cookie->rel = cookie->rels;
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index fa3dc62b81d..86643b4945a 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -384,9 +384,8 @@  elfNN_ia64_relax_section (bfd *abfd, asection *sec,
   symtab_hdr = &elf_symtab_hdr (abfd);
 
   /* Load the relocations for this section.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
-		      link_info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     return false;
 
diff --git a/bfd/elfnn-kvx.c b/bfd/elfnn-kvx.c
index 30db3234ec3..bf4b05edebe 100644
--- a/bfd/elfnn-kvx.c
+++ b/bfd/elfnn-kvx.c
@@ -1322,8 +1322,8 @@  elfNN_kvx_size_stubs (bfd *output_bfd,
 
 	      /* Get the relocs.  */
 	      internal_relocs
-		= _bfd_elf_link_read_relocs (input_bfd, section, NULL,
-					     NULL, info->keep_memory);
+		= _bfd_elf_link_read_relocs (input_bfd, section, NULL, NULL,
+					     info->keep_memory);
 	      if (internal_relocs == NULL)
 		goto error_ret_free_local;
 
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 880b7ce6ee8..17c714ab2c8 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -1921,9 +1921,9 @@  record_relr_non_got_relocs (bfd *input_bfd, struct bfd_link_info *info,
   struct riscv_elf_link_hash_table *htab = riscv_elf_hash_table (info);
   Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (input_bfd);
   struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
-  const Elf_Internal_Rela * relocs =
-	_bfd_elf_link_info_read_relocs (input_bfd, info, sec, NULL, NULL,
-					info->keep_memory);
+  const Elf_Internal_Rela *relocs
+    = _bfd_elf_link_info_read_relocs (input_bfd, info, sec, NULL, NULL,
+				      info->keep_memory);
   BFD_ASSERT (relocs != NULL);
 
   const Elf_Internal_Rela *rel = relocs;
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index b9f0294c325..4e8ffa5bc25 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -7348,8 +7348,8 @@  _bfd_mips_elf_eh_frame_address_size (bfd *abfd, const asection *sec)
       if (sec->reloc_count > 0)
 	{
 	  /* Load the relocations for this section.  */
-	  Elf_Internal_Rela *internal_relocs =
-	    _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, true);
+	  Elf_Internal_Rela *internal_relocs
+	    = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, true);
 	  if (internal_relocs == NULL)
 	    return 0;
 
@@ -8566,9 +8566,8 @@  _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 		  || section_allows_mips16_refs_p (o))
 		continue;
 
-	      sec_relocs
-		= _bfd_elf_link_read_relocs (abfd, o, NULL, NULL,
-					     info->keep_memory);
+	      sec_relocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL,
+						      info->keep_memory);
 	      if (sec_relocs == NULL)
 		return false;
 
@@ -8692,9 +8691,8 @@  _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 		  || section_allows_mips16_refs_p (o))
 		continue;
 
-	      sec_relocs
-		= _bfd_elf_link_read_relocs (abfd, o, NULL, NULL,
-					     info->keep_memory);
+	      sec_relocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL,
+						      info->keep_memory);
 	      if (sec_relocs == NULL)
 		return false;
 
@@ -14132,9 +14130,8 @@  _bfd_mips_elf_relax_section (bfd *abfd, asection *sec,
   symtab_hdr = &elf_symtab_hdr (abfd);
 
   /* Get a copy of the native relocations.  */
-  internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
-		      link_info->keep_memory));
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
   if (internal_relocs == NULL)
     goto error_return;
 
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index b9d937b0acd..c42de64cdfd 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -1125,8 +1125,7 @@  _bfd_x86_elf_link_relax_section (bfd *abfd ATTRIBUTE_UNUSED,
 
   /* Load the relocations for this section.  */
   internal_relocs =
-    _bfd_elf_link_info_read_relocs (abfd, info, input_section, NULL,
-				    (Elf_Internal_Rela *) NULL,
+    _bfd_elf_link_info_read_relocs (abfd, info, input_section, NULL, NULL,
 				    info->keep_memory);
   if (internal_relocs == NULL)
     return false;