[binutils-gdb] som foreign syms

Alan Modra amodra@sourceware.org
Fri Nov 21 23:34:22 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1529b30114989e324f9e555db9f994885c434e50

commit 1529b30114989e324f9e555db9f994885c434e50
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Nov 22 09:15:00 2025 +1030

    som foreign syms
    
    The makes use of the copy_private_symbol_data change in order to
    prevent bogus writes seen when running objcopy with binary input and
    som output.  It doesn't fix "FAIL: binary symbol", because the som
    backend also doesn't copy binary sections to the output, a fact that I
    didn't notice until I'd gone quite some way into fixing symbols..
    
            * som.c (som_bfd_copy_private_symbol_data): Make som symbols
            for non-som input.

Diff:
---
 bfd/som.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/bfd/som.c b/bfd/som.c
index adc9c55bd17..105800bc8fc 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -4351,7 +4351,9 @@ som_bfd_derive_misc_symbol_info (bfd *abfd ATTRIBUTE_UNUSED,
 
      The behavior of these flags is not well documentmented, so there
      may be bugs and some surprising interactions with other flags.  */
-  if (som_section_data (sym->section)
+  if (sym->section->owner != NULL
+      && sym->section->owner->xvec->flavour == bfd_target_som_flavour
+      && som_section_data (sym->section)
       && som_section_data (sym->section)->subspace_dict
       && info->symbol_scope == SS_UNIVERSAL
       && (info->symbol_type == ST_ENTRY
@@ -5349,9 +5351,17 @@ som_bfd_copy_private_symbol_data (bfd *ibfd,
 				  bfd *obfd ATTRIBUTE_UNUSED,
 				  asymbol **osymbol)
 {
-  /* One day we may try to grok other private data.  */
   if (ibfd->xvec->flavour != bfd_target_som_flavour)
-    return false;
+    {
+      /* The som backend makes use of som specific symbol fields
+	 when outputting symbols.  */
+      asymbol *osym = som_make_empty_symbol (obfd);
+      if (osym == NULL)
+	return false;
+      memcpy (osym, *isymbol, sizeof (*osym));
+      osym->the_bfd = obfd;
+      return true;
+    }
 
   /* The only private information we need to copy is the argument relocation
      bits.  */


More information about the Binutils-cvs mailing list