]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
a68: darwin specific support
authorJose E. Marchesi <jose.marchesi@oracle.com>
Sat, 11 Oct 2025 17:43:02 +0000 (19:43 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Sun, 30 Nov 2025 00:52:26 +0000 (01:52 +0100)
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 <iains.gcc@gmail.com>
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.

gcc/config/darwin.h
libiberty/simple-object-mach-o.c

index e23414c00b6d14eb87f55b5064c715f8fca3d6a5..ef356ad1419fb02085f0a577d3d4759b8125a064 100644 (file)
@@ -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 */
index e70e98ee30657348b6c6cb70cb711ee41eb4878f..5c992355b31f56aa52851491987ef974b157a5e2 100644 (file)
@@ -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);