[PATCH] strip: Remove SUNW_symtabsort and .SUNW_symtabnsort sections

H.J. Lu hjl.tools@gmail.com
Sun Sep 7 03:42:44 GMT 2025


On Solaris, SUNW_symtabsort and .SUNW_symtabnsort sections are linked
with .symtab and .strtab sections.  Since strip always removes .symtab
and .strtab sections, also removes .SUNW_symtabsort and .SUNW_symtabnsort
sections to silence:

strip: striprog: failed to find link section for section 27
strip: striprog: failed to find link section for section 27
strip: striprog: failed to find link section for section 28
strip: striprog: failed to find link section for section 28

	* objcopy.c (is_strip_section_1): Remove .SUNW_symtabsort
	and .SUNW_symtabnsort for Solaris.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 binutils/objcopy.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 3ac832157c8..a392f30108e 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1330,8 +1330,17 @@ is_mergeable_note_section (bfd * abfd, asection * sec)
 /* See if a non-group section is being removed.  */
 
 static bool
-is_strip_section_1 (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
+is_strip_section_1 (bfd *abfd, asection *sec)
 {
+  /* On Solaris, .SUNW_symtabsort and .SUNW_symtabnsort sections are
+     linked with .symtab and .strtab sections.  Since strip always
+     removes .symtab and .strtab sections, also removes .SUNW_symtabsort
+     and .SUNW_symtabnsort sections.  */
+  if (abfd->elf_target_os == is_solaris
+      && (strcmp (sec->name, ".SUNW_symtabsort") == 0
+	  || strcmp (sec->name, ".SUNW_symtabnsort") == 0))
+    return true;
+
   if (find_section_list (bfd_section_name (sec), false, SECTION_CONTEXT_KEEP)
       != NULL)
     return false;
-- 
2.51.0



More information about the Binutils mailing list