public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-3765] Darwin : Begin rework of zero-fill sections.
@ 2020-10-10 15:50 Iain D Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2020-10-10 15:50 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:dcf59c5c0100d0649d64ec948dbe24018d48b6a5

commit r11-3765-gdcf59c5c0100d0649d64ec948dbe24018d48b6a5
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sat Aug 22 17:40:20 2020 +0100

    Darwin : Begin rework of zero-fill sections.
    
    Much of the existing work in the Darwin BSS and common sections
    was to accommodate the PowerPC section anchors.  We want to segregate
    this, since it might become desirable to support section anchors for
    arm64.
    
    First revision (here) is to use the same section conventions as the Xcode
    toochains for BSS and COMMON.
    
    We also drop the constraint about putting small items into data/static data
    that was a work-around for Java issues (irrelevant for several editions).
    
    gcc/ChangeLog:
    
            * config/darwin.c (darwin_emit_local_bss): Amend section names to
            match system tools. (darwin_output_aligned_bss): Likewise.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/darwin-sections.c: Adjust test for renamed BSS and common
            sections.  Cater for 64 and 128 bit long doubles.

Diff:
---
 gcc/config/darwin.c                    | 42 ++++++++++++----------------------
 gcc/testsuite/gcc.dg/darwin-sections.c | 42 +++++++++++++++-------------------
 2 files changed, 33 insertions(+), 51 deletions(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index b64aaa7b1a7..23116484724 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -2384,11 +2384,7 @@ darwin_emit_local_bss (FILE *fp, tree decl, const char *name,
 			unsigned HOST_WIDE_INT size,
 			unsigned int l2align)
 {
-   /* 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))
+   if (DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL)
     {
       /* Put smaller objects in _static_data, where the section anchors system
 	 can get them.
@@ -2414,16 +2410,13 @@ darwin_emit_local_bss (FILE *fp, tree decl, const char *name,
     }
   else
     {
-      /* When we are on a non-section anchor target, we can get zero-sized
-	 items here.  However, all we need to do is to bump them to one byte
-	 and the section alignment will take care of the rest.  */
+      /* When we are on a non-section anchor target (or not using section
+	 anchors, we can get zero-sized items here.  However, all we need to
+	 do is to bump them to one byte and the section alignment will take
+	 care of the rest.  */
       char secnam[64];
-      unsigned int flags ;
-      snprintf (secnam, 64, "__DATA,__%sbss%u", ((size)?"":"zo_"),
-						(unsigned) l2align);
-      /* We can't anchor (yet, if ever) in zerofill sections, because we can't
-	 switch to them and emit a label.  */
-      flags = SECTION_BSS|SECTION_WRITE|SECTION_NO_ANCHOR;
+      snprintf (secnam, 64, "__DATA,__bss");
+      unsigned int flags = SECTION_BSS|SECTION_WRITE|SECTION_NO_ANCHOR;
       in_section = get_section (secnam, flags, NULL);
       fprintf (fp, "\t.zerofill %s,", secnam);
       assemble_name (fp, name);
@@ -2434,7 +2427,7 @@ darwin_emit_local_bss (FILE *fp, tree decl, const char *name,
 	fprintf (fp, "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",
 		 size, (unsigned) l2align);
       else
-	fprintf (fp, "," HOST_WIDE_INT_PRINT_UNSIGNED"\n", size);
+	fprintf (fp, "," HOST_WIDE_INT_PRINT_UNSIGNED",0\n", size);
     }
 
   (*targetm.encode_section_info) (decl, DECL_RTL (decl), false);
@@ -2559,9 +2552,8 @@ fprintf (fp, "# albss: %s (%lld,%d) ro %d cst %d stat %d com %d"
       return;
     }
 
-  /* 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))
+  /* So we have a public symbol.  */
+  if (DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL)
     {
       /* 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
@@ -2586,16 +2578,10 @@ fprintf (fp, "# albss: %s (%lld,%d) ro %d cst %d stat %d com %d"
     }
   else
     {
+      /* Section anchors not in use.  */
+      unsigned int flags = SECTION_BSS|SECTION_WRITE|SECTION_NO_ANCHOR;
       char secnam[64];
-      unsigned int flags ;
-      /* When we are on a non-section anchor target, we can get zero-sized
-	 items here.  However, all we need to do is to bump them to one byte
-	 and the section alignment will take care of the rest.  */
-      snprintf (secnam, 64, "__DATA,__%spu_bss%u", ((size)?"":"zo_"), l2align);
-
-      /* We can't anchor in zerofill sections, because we can't switch
-	 to them and emit a label.  */
-      flags = SECTION_BSS|SECTION_WRITE|SECTION_NO_ANCHOR;
+      snprintf (secnam, 64, "__DATA,__common");
       in_section = get_section (secnam, flags, NULL);
       fprintf (fp, "\t.zerofill %s,", secnam);
       assemble_name (fp, name);
@@ -2605,7 +2591,7 @@ fprintf (fp, "# albss: %s (%lld,%d) ro %d cst %d stat %d com %d"
       if (l2align)
 	fprintf (fp, "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", size, l2align);
       else
-	fprintf (fp, "," HOST_WIDE_INT_PRINT_UNSIGNED"\n", size);
+	fprintf (fp, "," HOST_WIDE_INT_PRINT_UNSIGNED",0\n", size);
     }
   (* targetm.encode_section_info) (decl, DECL_RTL (decl), false);
 }
diff --git a/gcc/testsuite/gcc.dg/darwin-sections.c b/gcc/testsuite/gcc.dg/darwin-sections.c
index 276ffa391ed..dbe37027f89 100644
--- a/gcc/testsuite/gcc.dg/darwin-sections.c
+++ b/gcc/testsuite/gcc.dg/darwin-sections.c
@@ -13,45 +13,41 @@ e_s ea;
 /* { dg-final { scan-assembler ".comm\[\t \]_ub,1" } } */
 /* { dg-final { scan-assembler ".comm\[\t \]_ea,1" } } */
 
-/* These should go into .data */
+/* These should go into __DATA,__common */
 char a = 0;
 short b = 0;
-/* { dg-final { scan-assembler ".globl _a.*.data.*.space\[\t \]1" } } */
-/* { dg-final { scan-assembler ".globl _b.*.data.*.space\[\t \]2" } } */
-
-/* These should go into __pu_bssN */
 long long d = 0;
 float e = 0;
 double f = 0;
 long double g = 0.L;
 long long al_256 __attribute__((aligned (256))) = 0;
-/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss3,_d,8,3" } } */
-/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss2,_e,4,2" } } */
-/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss3,_f,8,3" } } */
-/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss4,_g,16,4" } } */
-/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss8,_al_256,8,8" } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__common,_a,1,0} } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__common,_b,2,1} } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__common,_d,8,3} } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__common,_e,4,2} } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__common,_f,8,3} } } */
+/* long double can be 64 or 128 bits depending on the Darwin subtarget.  */
+/* { dg-final { scan-assembler {.zerofill __DATA,__common,_g,(16,4|8,3)} } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__common,_al_256,8,8} } } */
 
-/* This should go into __zo_bss0 */
+/* These should go into __DATA,__bss */
 static e_s sea;
-/* { dg-final { scan-assembler ".zerofill __DATA,__zo_bss0,_sea,1" } } */
-
-/* These should go into .static_data */
 static char sa ;
 static short sb ;
-/* { dg-final { scan-assembler ".static_data.*_sa:.*.space\[\t \]1" } } */
-/* { dg-final { scan-assembler ".static_data.*_sb:.*.space\[\t \]2" } } */
-
-/* These should go into _bssN */
 static long long sd;
 static float se ;
 static double sf ;
 static long double sg;
 static long long sal_256 __attribute__((aligned (2048)));
-/* { dg-final { scan-assembler ".zerofill __DATA,__bss3,_sd,8,3" } } */
-/* { dg-final { scan-assembler ".zerofill __DATA,__bss2,_se,4,2" } } */
-/* { dg-final { scan-assembler ".zerofill __DATA,__bss3,_sf,8,3" } } */
-/* { dg-final { scan-assembler ".zerofill __DATA,__bss4,_sg,16,4" } } */
-/* { dg-final { scan-assembler ".zerofill __DATA,__bss11,_sal_256,8,11" } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sea,1,0} } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sa,1,0} } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sb,2,1} } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sd,8,3} } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_se,4,2} } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sf,8,3} } } */
+/* long double can be 64 or 128 bits depending on the Darwin subtarget.  */
+/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sg,(16,4|8,3)} } } */
+/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sal_256,8,11} } } */
 
 long long foo (int x)
 {


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-10 15:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-10 15:50 [gcc r11-3765] Darwin : Begin rework of zero-fill sections Iain D Sandoe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).