https://gcc.gnu.org/g:0fdf9b30c6f9dd8da349bd4dc754313d6e6834da

commit r16-5775-g0fdf9b30c6f9dd8da349bd4dc754313d6e6834da
Author: Jose E. Marchesi <[email protected]>
Date:   Sat Oct 11 19:43:02 2025 +0200

    a68: darwin specific support
    
    This commit:
    
    - Adapts specs in config/darwin.h for libga68.a.
    
    - Amends section processing for non-LTO use in libibery on Darwin.
    
      The initial implementation of the Mach-O simple object code was
      mainly targeting LTO cases.  The implementation was not suitable for
      cases where we are just looking for a regular named section.
    
    Signed-off-by: Iain Sandoe <[email protected]>
    
    gcc/ChangeLog
    
            * config/darwin.h: Adapt specs for libga68.a.
    
    libiberty/ChangeLog:
    
            * simple-object-mach-o.c
            (simple_object_mach_o_segment): Handle non-LTO sections.

Diff:
---
 gcc/config/darwin.h              |  5 +++++
 libiberty/simple-object-mach-o.c | 25 +++++++------------------
 2 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index e23414c00b6d..ef356ad1419f 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -523,6 +523,7 @@ extern GTY(()) int darwin_ms_struct;
    %{static|static-libgcc|static-libgcobol:%:replace-outfile(-lgcobol 
libgcobol.a%s)}\
    
%{static|static-libgcc|static-libstdc++|static-libgfortran:%:replace-outfile(-lgomp
 libgomp.a%s)}\
    %{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ 
libstdc++.a%s)}\
+   %{static|static-libga68:%:replace-outfile(-lga68 libga68.a%s)}\
    %{static|static-libgm2:%:replace-outfile(-lm2pim libm2pim.a%s)}\
    %{static|static-libgm2:%:replace-outfile(-lm2iso libm2iso.a%s)}\
    %{static|static-libgm2:%:replace-outfile(-lm2min libm2min.a%s)}\
@@ -1301,4 +1302,8 @@ extern void darwin_driver_init (unsigned int *,struct 
cl_decoded_option **);
 #undef BTF_INFO_SECTION_NAME
 #define BTF_INFO_SECTION_NAME "__CTF_BTF,__btf,regular,debug"
 
+/* Algol68 */
+#undef A68_EXPORT_SECTION_NAME
+#define A68_EXPORT_SECTION_NAME "__a68_exports"
+
 #endif /* CONFIG_DARWIN_H */
diff --git a/libiberty/simple-object-mach-o.c b/libiberty/simple-object-mach-o.c
index e70e98ee3065..5c992355b31f 100644
--- a/libiberty/simple-object-mach-o.c
+++ b/libiberty/simple-object-mach-o.c
@@ -617,7 +617,6 @@ simple_object_mach_o_segment (simple_object_read *sobj, 
off_t offset,
       char *name;
       off_t secoffset;
       size_t secsize;
-      int l;
 
       sechdr = secdata + i * sechdrsize;
 
@@ -669,12 +668,15 @@ simple_object_mach_o_segment (simple_object_read *sobj, 
off_t offset,
            }
        }
 
+      memset (namebuf, 0, sizeof (namebuf));
+      /* Copy the section name so we can append a null to make it into a
+        c-string (Mach-o section names are not terminated).  */
+      memcpy (namebuf, sechdr + sectname_offset, MACH_O_NAME_LEN);
+      namebuf[MACH_O_NAME_LEN] = '\0';
+      name = &namebuf[0];
+      /* Maybe override this if we have long section name extension.  */
       if ((gnu_sections_found & SOMO_LONGN_PRESENT) != 0)
        {
-         memcpy (namebuf, sechdr + sectname_offset, MACH_O_NAME_LEN);
-         namebuf[MACH_O_NAME_LEN] = '\0';
-
-         name = &namebuf[0];
          if (strtab != NULL && name[0] == '_' && name[1] == '_')
            {
              unsigned long stringoffset;
@@ -696,19 +698,6 @@ simple_object_mach_o_segment (simple_object_read *sobj, 
off_t offset,
                }
          }
        }
-      else
-       {
-          /* Otherwise, make a name like __segment,__section as per the
-             convention in mach-o asm.  */
-         name = &namebuf[0];
-         memcpy (namebuf, (char *) sechdr + segname_offset, MACH_O_NAME_LEN);
-         namebuf[MACH_O_NAME_LEN] = '\0';
-         l = strlen (namebuf);
-         namebuf[l] = ',';
-         memcpy (namebuf + l + 1, (char *) sechdr + sectname_offset,
-                 MACH_O_NAME_LEN);
-         namebuf[l + 1 + MACH_O_NAME_LEN] = '\0';
-       }
 
       simple_object_mach_o_section_info (omr->is_big_endian, is_32, sechdr,
                                         &secoffset, &secsize);

Reply via email to