From aa73ec10a5b2503760042bcfd031d3f17af64c87 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss <creatorsmithmdt@gmail.com>
Date: Thu, 17 Nov 2022 14:05:59 +1100
Subject: [PATCH 07/56] Darwin: Re-add Java workaround constraint about putting
 small items into data/static data.

gcc/ChangeLog:

	* config/darwin.cc (darwin_emit_local_bss): Re-add Java workaround constraint about putting small items into data/static data.
	(fprintf): Likewise.
---
 gcc/config/darwin.cc | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index 1b3de338926..8986e878709 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -2482,7 +2482,11 @@ darwin_emit_local_bss (FILE *fp, tree decl, const char *name,
 			unsigned HOST_WIDE_INT size,
 			unsigned int l2align)
 {
-   if (DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL)
+   /* FIXME: We have a fudge to make this work with Java even when the target does
+   not use sections anchors -- Java seems to need at least one small item in a
+   non-zerofill segment.   */
+   if ((DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL)
+       || (size && size <= 2))
     {
       /* Put smaller objects in _static_data, where the section anchors system
 	 can get them.
@@ -2649,8 +2653,9 @@ fprintf (fp, "# albss: %s (%lld,%d) ro %d cst %d stat %d com %d"
       return;
     }
 
-  /* So we have a public symbol.  */
-  if (DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL)
+  /* So we have a public symbol (small item fudge for Java, see above).  */
+  if ((DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL)
+       || (size && size <= 2))
     {
       /* Put smaller objects in data, where the section anchors system can get
 	 them.  However, if they are zero-sized punt them to yet a different
-- 
2.38.1

Reply via email to