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 <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.
This commit is contained in:
Jose E. Marchesi 2025-10-11 19:43:02 +02:00
parent 0d787df6f2
commit 0fdf9b30c6
2 changed files with 12 additions and 18 deletions

View 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 */

View 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);