comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: How do I disable elaboration code on this
Date: Sat, 09 Apr 2011 23:05:43 +0100
Date: 2011-04-09T23:05:43+01:00	[thread overview]
Message-ID: <m2hba7t70o.fsf@pushface.org> (raw)
In-Reply-To: 8739lrqkuu.fsf@ludovic-brenta.org

Ludovic Brenta <ludovic@ludovic-brenta.org> writes:

> Simon Wright <simon@pushface.org> writes on comp.lang.ada:
>> Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
>>
>>> Simon Wright <simon@pushface.org> writes on comp.lang.ada:
>>>> Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org> 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.)



  reply	other threads:[~2011-04-09 22:05 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-09 13:58 How do I disable elaboration code on this Lucretia
2011-04-09 16:57 ` Jeffrey Carter
2011-04-09 17:01   ` Simon Wright
2011-04-09 17:44     ` Ludovic Brenta
2011-04-09 19:19       ` Simon Wright
2011-04-09 19:32         ` Jeffrey Carter
2011-04-10  9:06           ` Lucretia
2011-04-10  9:31             ` Simon Wright
2011-04-09 19:35         ` Ludovic Brenta
2011-04-09 22:05           ` Simon Wright [this message]
2011-04-10  5:39             ` Simon Wright
2011-04-10 17:20   ` Lucretia
2011-04-10 20:12     ` Jeffrey Carter
2011-04-10 20:47     ` Georg Bauhaus
2011-04-10 21:19       ` Lucretia
2011-04-11  5:08         ` Lucretia
2011-04-11  6:28           ` Simon Wright
2011-04-11  8:54             ` Lucretia
2011-04-11 10:10               ` Simon Wright
2011-04-11 11:59                 ` Simon Clubley
2011-04-11 18:30                   ` Simon Wright
2011-04-11 19:12                     ` Simon Wright
2011-04-11 19:50                       ` Simon Wright
2011-04-11 21:40                       ` Lucretia
2011-04-11 23:12                         ` Lucretia
2011-04-11 23:16                           ` Lucretia
2011-04-11 23:31                           ` Lucretia
2011-04-12  5:22                             ` Simon Wright
2011-04-12 17:07                             ` Simon Clubley
2011-04-13 16:53                       ` Simon Wright
2011-04-15  8:38                       ` Simon Wright
2011-04-11 23:08                   ` Lucretia
2011-04-12 11:50                     ` Simon Clubley
2011-04-12 16:48                       ` Lucretia
2011-04-11 11:19               ` Georg Bauhaus
2011-04-11 13:50                 ` Simon Wright
2011-04-14 19:19               ` Florian Weimer
2011-04-10 16:34 ` Rolf
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox