From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,69431b06fe9a3239 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: How do I disable elaboration code on this Date: Sat, 09 Apr 2011 23:05:43 +0100 Organization: A noiseless patient Spider Message-ID: References: <58bc4fb4-5f6a-48d6-9c98-0dde7ac619df@p16g2000vbo.googlegroups.com> <87ipunqpyv.fsf@ludovic-brenta.org> <8739lrqkuu.fsf@ludovic-brenta.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx03.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="30844"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/mADajqcEPmBAc7cdveKvtpa/31jg2yw=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:ywiUZYc3jUZMsiAa0dDxhPu8Pxc= sha1:JJHgW3DUXP0TF6dyaMk/pMevcp0= Xref: g2news2.google.com comp.lang.ada:19707 Date: 2011-04-09T23:05:43+01:00 List-Id: Ludovic Brenta writes: > Simon Wright writes on comp.lang.ada: >> Ludovic Brenta writes: >> >>> Simon Wright writes on comp.lang.ada: >>>> Jeffrey Carter writes: >>>> >>>>> On 04/09/2011 06:58 AM, Lucretia wrote: >>>>>> The following code will not compile no matter what I do. Basically, I >>>>>> want to write the startup code for Cortex-M3 in Ada with no assembly. >>>>>> So, the ISR code needs to be elaboration free as it's the first bit of >>>>>> code that would run on reset. >>>>> >>>>>> Vector : constant Vectors := >>>>>> (Dummy'Access, >>>>>> Dummy'Access, >>>>>> Dummy'Access, >>>>>> Dummy'Access); >>>>>> pragma Convention (C, Vector); >>>>>> for Vector'Address use Addr; >>> But the vector being in Flash ROM, the Ada code needs not and indeed may >>> not initialize it, so I think Jeffrey's reply is correct. The pragma >>> Import and the address clause will make the actual vectors (in ROM) >>> visible to the Ada program. >> >> That would be true if the vector was built in a separate C or ASM >> file, but Luke wants to do the whole thing in Ada and then write it to >> Flash. See above: "Basically, I want to write the startup code for >> Cortex-M3 in Ada with no assembly." > > The vector can and must be built and burned to Flash separately, by an > Ada program of course :) This Ada program cannot write to Flash, it can > only read the vector previously stored there with no elaboration and no > initialization. This is very similar to things I did at Barco avionics > a few years ago (I even wrote the driver for writing to the particular > Flash device in pure Ada). Well, you've done it and I haven't! The process I deduced from Luke's question ends up with taking an executable image (including the ISV, which is at 16#0000_0000# after reset) and burning it to Flash using some utility or other (probably part of the SDK). So, can he find a way of generating this executable from just Ada? It's the fact that Vector is at 16#0000_0000# that's causing the problem (there is no elaboration code if the linker is allowed to put Vector where it likes). So clearly GNAT doesn't know how to make ld do what's wanted and has to do it the hard way. Is the missing bit perhaps the use of what on VAX used to be called program sections (PSECTs)? GNU ld includes the option --section-start sectionname=org Locate a section in the output file at the absolute address given by org. You may use this option as many times as necessary to locate multiple sections in the command line. org must be a single hexadecimal integer; for compatibility with other linkers, you may omit the leading 0x usually associated with hexadecimal values. so I suppose what's needed is a way to force Vector into a specific named section. What about pragma Linker_Section? http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gnat_rm/Pragma-Linker_005fSection.html I can't go much further here (what's legal as the name of a section depends on the assembler/linker conventions), but this pragma Linker_Section (Vector, "initial_isv,0"); resulted in this .globl _isr__vector .section initial_isv .align 5 _isr__vector: .quad _isr__dummy .quad _isr__dummy .quad _isr__dummy .quad _isr__dummy .const (This is a 64-bit compiler, hence the .quad's. No idea about .align 5.)