Minor objcopy optimisation for copy_relocations_in_section

Message ID ZHkxDSYR0EtVi6dY@squeak.grove.modra.org
State Accepted
Headers
Series Minor objcopy optimisation for copy_relocations_in_section |

Checks

Context Check Description
snail/binutils-gdb-check success Github commit url

Commit Message

Alan Modra June 2, 2023, midnight UTC
  * objcopy (copy_relocations_in_section): Don't read the relocs
	for STRIP_ALL if keep_specific_htab is empty.
  

Patch

diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 49d54bff9b2..ac40da87018 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -4343,6 +4343,8 @@  copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
   /* Core files and DWO files do not need to be relocated.  */
   if (bfd_get_format (obfd) == bfd_core
       || strip_symbols == STRIP_NONDWO
+      || (strip_symbols == STRIP_ALL
+	  && htab_elements (keep_specific_htab) == 0)
       || discard_relocations (ibfd, isection))
     relsize = 0;
   else