[committed] ada: Fix up handling of ghost units [PR104027]

Message ID 20220114230410.GQ2646553@tucnak
State Committed
Headers
Series [committed] ada: Fix up handling of ghost units [PR104027] |

Commit Message

Jakub Jelinek Jan. 14, 2022, 11:04 p.m. UTC
  Hi!

As reported, libgnat-12.so gets PT_GNU_STACK RWE, which means it doesn't
work in some SELinux configurations.
This is caused by the a-nbnbig.o file, which is a ghost unit and since
r12-5670 the FE emits an object file for it, but exits before compile_file
has a chance to finalize it e.g. with targetm.asm_out.file_end ()
that emits the .note.GNU-stack section on various linux targets.

Fixed by not existing but instead returning early to the caller.

Bootstrapped/regtested on x86_64-linux, preapproved in the PR,
committed to trunk.

2022-01-14  Andrew Pinski  <apinski@marvell.com>

	PR ada/104027
	* gnat1drv.adb (Gnat1drv): After Back_End.Gen_Or_Update_Object_File
	goto End_Of_Program.


	Jakub
  

Patch

--- gcc/ada/gnat1drv.adb
+++ gcc/ada/gnat1drv.adb
@@ -1429,6 +1429,11 @@  begin
             Ecode := E_Success;
             Back_End.Gen_Or_Update_Object_File;
 
+            --  Use a goto instead of calling Exit_Program so that finalization
+            --  occurs normally.
+
+            goto End_Of_Program;
+
          --  Otherwise the unit is missing a crucial piece that prevents code
          --  generation.