From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: How can I get this data into the .data section of the binary? Date: Wed, 17 Jun 2020 21:55:04 -0500 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Thu, 18 Jun 2020 02:55:06 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="4665"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader01.eternal-september.org comp.lang.ada:59112 List-Id: "Luke A. Guest" wrote in message news:rcaicd$ifh$1@gioia.aioe.org... ... > According to 10.2.1 it should be possible: > > is important that programs be able to declare data structures that > are link-time initialized with aggregates, string_literals, and > concatenations thereof. etc. > > Even adding pragma Preelaborable_Initialization (x) for each of the > types, doesn't do anything. The requirement in the Ada Standard is that one should preelaborate data if the containing package is preelaborated. There's no requirement otherwise, and since it is an annex C requirement, it is not required of all Ada compilers. Janus/Ada, for instance, has no concept of an initialized but modifiable data segment so it can't do precisely what you want. (It does put aggregates into such a segment, but it will copy them if they are used to initialize variables.) We did that to match the RAM/ROM split of many embedded systems. Anyway, I would expect a compiler to do it if it is possible. But it very often isn't possible for one reason or another (for instance, static aggregates often are *way* bigger than dynamic initialization, so for a compiler that tries to minimize memory usage, static initialization may not be a good idea in some cases). The better question is why you care? One ought to be concerned about whether performance is good enough for your application, and it's highly unlikely that the load time would have any impact on that whatsoever. (And as previously noted, static initialization can require more work to load a program.) On a desktop, antivirus overhead is way more than any sort of load cost/saving from the memory layout. (The situation can be different on a bare machine, of course.) Randy.