diff mbox series

[Darwin,committed] Suppress emitting empty ctor/dtor sections.

Message ID 23002353-E54E-40C2-A8FA-026589F8C06D@sandoe.co.uk
State New
Headers show
Series [Darwin,committed] Suppress emitting empty ctor/dtor sections. | expand

Commit Message

Iain Sandoe Oct. 12, 2019, 8 p.m. UTC
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.

tested on x86_64-darwin16, powerpc-darwin9,
applied to mainline
thanks
Iain

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.
diff mbox series

Patch

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 539ef759d3..ddce9f8c8b 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -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);