[Darwin] Suppress emitting empty ctor/dtor sections.
authorIain Sandoe <iains@gcc.gnu.org>
Sat, 12 Oct 2019 19:20:43 +0000 (19:20 +0000)
committerIain Sandoe <iains@gcc.gnu.org>
Sat, 12 Oct 2019 19:20:43 +0000 (19:20 +0000)
Older versions of GCC emit empty .constructor/.destructor sections
whenever building for C++. In fact, these sections are only used for
kernel mode code - so don't emit them unless that's what we're
building.

gcc/ChangeLog:

2019-10-12  Iain Sandoe  <iain@sandoe.co.uk>

* config/darwin.c (darwin_file_end): Only emit empty CTOR/DTOR
sections when building kernel extension code.

From-SVN: r276923

gcc/config/darwin.c

index 539ef759d31ea6bfacaf5edc06ef949761974a3a..ddce9f8c8bbb9fd4fcc184080d33dbba2c158cd4 100644 (file)
@@ -2931,8 +2931,9 @@ darwin_file_end (void)
      }
 
   machopic_finish (asm_out_file);
-  if (lang_GNU_CXX ())
+  if (flag_apple_kext)
     {
+      /* These sections are only used for kernel code.  */
       switch_to_section (darwin_sections[constructor_section]);
       switch_to_section (darwin_sections[destructor_section]);
       ASM_OUTPUT_ALIGN (asm_out_file, 1);