[Ada] Static intialization with pragma Linker_Section
Arnaud Charlet
charlet@adacore.com
Tue Apr 25 09:47:00 GMT 2017
This patch is an improvement that causes an array object that has a
pragma Linker_Section with a compile-time-known initial value to be
statically initialized in place in the appropriate section.
Tested on x86_64-pc-linux-gnu, committed on trunk
2017-04-25 Bob Duff <duff@adacore.com>
* freeze.adb (Freeze_Object_Declaration): Do
not Remove_Side_Effects if there is a pragma Linker_Section,
because in that case we want static initialization in the
appropriate section.
-------------- next part --------------
Index: freeze.adb
===================================================================
--- freeze.adb (revision 247155)
+++ freeze.adb (working copy)
@@ -3197,12 +3197,15 @@
-- Similar processing is needed for aspects that may affect
-- object layout, like Alignment, if there is an initialization
- -- expression.
+ -- expression. We don't do this if there is a pragma Linker_Section,
+ -- because it would prevent the back end from statically initializing
+ -- the object; we don't want elaboration code in that case.
if Has_Delayed_Aspects (E)
and then Expander_Active
and then Is_Array_Type (Etype (E))
and then Present (Expression (Parent (E)))
+ and then No (Linker_Section_Pragma (E))
then
declare
Decl : constant Node_Id := Parent (E);
More information about the Gcc-patches
mailing list