comp.lang.ada
 help / color / mirror / Atom feed
* Curiousity: pragma No_Run_Time for Gnat
@ 2001-09-24 19:02 Marin David Condic
  2001-09-24 21:14 ` Sergey Koshcheyev
  0 siblings, 1 reply; 22+ messages in thread
From: Marin David Condic @ 2001-09-24 19:02 UTC (permalink / raw)


The GNAT reference manual says this about pragma No_Run_Time:

====================================
pragma No_Run_Time
Syntax:
pragma No_Run_Time;

This is a configuration pragma that makes sure the user code does not use
nor need anything from the GNAT run time. This is mostly useful in context
where code certification is required. Please consult the GNORT product
documentation for additional information.
=======================================

Would this mean that the Gnat 3.13p I have installed on my PC here would
generate code that assumes nothing about the environment other than the
processor it is targeting? (Assuming that the code did not contain
constructs for which runtime is required.) That is to say - if I write a
procedure that contains a "pragma No_Run_Time" directive, that if I can get
it past the compiler, I'll have raw machine code with no OS calls, no
runtime calls, nothing except x86 machine code?

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/






^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-24 19:02 Marin David Condic
@ 2001-09-24 21:14 ` Sergey Koshcheyev
  2001-09-24 21:54   ` Marin David Condic
  2001-09-25  7:43   ` Peter Amey
  0 siblings, 2 replies; 22+ messages in thread
From: Sergey Koshcheyev @ 2001-09-24 21:14 UTC (permalink / raw)



"Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org> wrote in
message news:9oo006$fdf$1@nh.pace.co.uk...
> The GNAT reference manual says this about pragma No_Run_Time:
>
> <snip>
>
> Would this mean that the Gnat 3.13p I have installed on my PC here would
> generate code that assumes nothing about the environment other than the
> processor it is targeting? (Assuming that the code did not contain
> constructs for which runtime is required.) That is to say - if I write a
> procedure that contains a "pragma No_Run_Time" directive, that if I can
get
> it past the compiler, I'll have raw machine code with no OS calls, no
> runtime calls, nothing except x86 machine code?

My experience (I don't have the GNORT documentation) was that GNAT indeed
produced "self-contained" executables when this pragma was used, except it
once needed to call memcpy from the C library (when copying arrays), but I
linked that in statically.

Serge Robyns has written a small OS kernel using GNAT and pragma No_Run_Time
this way. It can be found at http://web.wanadoo.be/rc.s/AdaOS/index.html

Sergey Koshcheyev





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-24 21:14 ` Sergey Koshcheyev
@ 2001-09-24 21:54   ` Marin David Condic
  2001-09-25  7:32     ` Sergey Koshcheyev
  2001-09-25  7:36     ` Jean-Marc Bourguet
  2001-09-25  7:43   ` Peter Amey
  1 sibling, 2 replies; 22+ messages in thread
From: Marin David Condic @ 2001-09-24 21:54 UTC (permalink / raw)


O.K. I've bookmarked that. I'll look at it as soon as I can get that elusive
Round Tuit.

I'm also wondering if it would eschew any BIOS calls or if the BIOS would be
presumed? I'm wondering if I can really get some sort of "pure" x86 code?

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"Sergey Koshcheyev" <serko84@hotmail.com> wrote in message
news:9oo7ne$145d$1@ns.felk.cvut.cz...
>
>
> My experience (I don't have the GNORT documentation) was that GNAT indeed
> produced "self-contained" executables when this pragma was used, except it
> once needed to call memcpy from the C library (when copying arrays), but I
> linked that in statically.
>
> Serge Robyns has written a small OS kernel using GNAT and pragma
No_Run_Time
> this way. It can be found at http://web.wanadoo.be/rc.s/AdaOS/index.html
>
> Sergey Koshcheyev
>
>





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-24 21:54   ` Marin David Condic
@ 2001-09-25  7:32     ` Sergey Koshcheyev
  2001-09-25 14:00       ` Marin David Condic
  2001-09-25  7:36     ` Jean-Marc Bourguet
  1 sibling, 1 reply; 22+ messages in thread
From: Sergey Koshcheyev @ 2001-09-25  7:32 UTC (permalink / raw)


"Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org> wrote in
message news:9ooa2p$j91$1@nh.pace.co.uk...
> O.K. I've bookmarked that. I'll look at it as soon as I can get that
elusive
> Round Tuit.

While I was doing a web search to find out what you meant (I think I
understand the idiom now), I found several webpages providing Round Tuits to
people who need them :-)

> I'm also wondering if it would eschew any BIOS calls or if the BIOS would
be
> presumed? I'm wondering if I can really get some sort of "pure" x86 code?

I don't know exactly what you mean by "pure" x86 code. What you get from the
compiler on x86 is a 32-bit executable in the platform-specific executable
format (ELF on Linux, PE on Win32) which isn't linked to GNAT libraries,
though I think it may be linked dynamically to the C library. Linker
switch -nostdlib can be used to overcome this and get a completely
stand-alone executable (tested on Linux). Another linker switch can be used
to link the C library in statically (also tested on Linux). GNAT doesn't
insert any BIOS calls in the generated code when pragma No_Run_Time is used.

Sergey Koshcheyev

> MDC
> --
> Marin David Condic
> Senior Software Engineer
> Pace Micro Technology Americas    www.pacemicro.com
> Enabling the digital revolution
> e-Mail:    marin.condic@pacemicro.com
> Web:      http://www.mcondic.com/






^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-24 21:54   ` Marin David Condic
  2001-09-25  7:32     ` Sergey Koshcheyev
@ 2001-09-25  7:36     ` Jean-Marc Bourguet
  1 sibling, 0 replies; 22+ messages in thread
From: Jean-Marc Bourguet @ 2001-09-25  7:36 UTC (permalink / raw)


Marin David Condic wrote:
> 
> O.K. I've bookmarked that. I'll look at it as soon as I can get that elusive
> Round Tuit.
> 
> I'm also wondering if it would eschew any BIOS calls or if the BIOS would be
> presumed? I'm wondering if I can really get some sort of "pure" x86 code?

When I played with it, the code generated assumed the processor was in protected
mode.  If you add that this mode is available for other processors and even for x86
using the bios would reduce its utility for very little gain (what part of the bios
would you find useful for code generation purpose, especially in protected mode?)
I'd be very surprised to find call to the bios.

-- Jean-Marc



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-24 21:14 ` Sergey Koshcheyev
  2001-09-24 21:54   ` Marin David Condic
@ 2001-09-25  7:43   ` Peter Amey
  2001-09-25 14:02     ` Marin David Condic
  1 sibling, 1 reply; 22+ messages in thread
From: Peter Amey @ 2001-09-25  7:43 UTC (permalink / raw)


[snip]
> linked that in statically.
> 
> Serge Robyns has written a small OS kernel using GNAT and pragma No_Run_Time
> this way. It can be found at http://web.wanadoo.be/rc.s/AdaOS/index.html

You might also like to take a look at: "Re-engineering a safety-critical
system with SPARK95 and GNORT" under "Publications" at www.sparkada.com


Peter

-- 
---------------------------------------------------------------------------   
      __         Peter Amey, Product Manager
        )                    Praxis Critical Systems Ltd
       /                     20, Manvers Street, Bath, BA1 1PX
      / 0        Tel: +44 (0)1225 466991
     (_/         Fax: +44 (0)1225 469006
                 http://www.praxis-cs.co.uk/

--------------------------------------------------------------------------



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-25 14:09 M. A. Alves
@ 2001-09-25 13:05 ` chris.danx
  2001-09-25 13:07 ` Jacob Sparre Andersen
  2001-09-25 13:37 ` Sergey Koshcheyev
  2 siblings, 0 replies; 22+ messages in thread
From: chris.danx @ 2001-09-25 13:05 UTC (permalink / raw)


> But note that for OS execution it would be acceptable to depend on the
> BIOS (at least early on the startup process); after all the BIOS is there
> and it is running before the OS.  *** But it is not acceptable at all for
> execution to depend on another OS. ***
>
> In fact, I have been thinking in terms of a MIOS (Minimal Input/Output
> System) package providing access to the "minimal system" I have suggested
> before (Ada_OS talk) as a starting target (floppy, keyboard, screen): MIOS
> would probably be implemented with BIOS services: hence, in part, the
> tribute in its name.

Note: if you want a pmode OS for the x86+ this could only work via v86 mode
or only in the very early stages of bootup (which GRUB might be good for).
Using BIOS via v86 would be slow and OS developers only do this for vesa
(because graphics cards -- in particular those with nVidia chipsets -- don't
release the prog. specs for their cards).  However for initial start up such
a system would be good but you may need a 16bit compiler for real mode
stuff.

Keyboard handlers for pmode seem to be easy enough, so too does the screen.
In fact programming the screen (for text, graphics programming is more
complex) is really easy.  You write to address 0xb8000 in
attribute/character pairs for colour memory or something (don't quote me on
that) in pmode.


> BTW, what is GRUB?  And where is GNORT?

GRUB is a bootloader for OSes, in particular it can boot multiple OS from a
menu with a multiboot compliant header, *I think* (but it's supposed to boot
almost anything).  GNORT is a some kind of GNAT variant provided by ACT,
which seems to be have discontinued and either integrated into or changed
it's name to GNAT Pro Bare Board.







^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-25 14:09 M. A. Alves
  2001-09-25 13:05 ` chris.danx
@ 2001-09-25 13:07 ` Jacob Sparre Andersen
  2001-09-25 13:37 ` Sergey Koshcheyev
  2 siblings, 0 replies; 22+ messages in thread
From: Jacob Sparre Andersen @ 2001-09-25 13:07 UTC (permalink / raw)


M�rio:

> BTW, what is GRUB?

A boot loader.

Jacob
-- 
"Unix, Perl og Ole har man for at slippe for at g�re
 arbejdet selv."



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
       [not found] <Pine.LNX.4.33.0109251343310.2841-100000@lagoa.niaad.liacc.up.pt>
@ 2001-09-25 13:20 ` David C. Hoos
  0 siblings, 0 replies; 22+ messages in thread
From: David C. Hoos @ 2001-09-25 13:20 UTC (permalink / raw)
  To: comp.lang.ada

GRUB stands for GRand Unified Bootloader

----- Original Message ----- 
From: "M. A. Alves" <maa@liacc.up.pt>
To: <comp.lang.ada@ada.eu.org>
Sent: Tuesday, September 25, 2001 9:09 AM
Subject: Re: Curiousity: pragma No_Run_Time for Gnat


<snip>

> BTW, what is GRUB?  And where is GNORT?
> 
> Thanks,
> 
> -- 
>    ,
>  M A R I O   data miner, LIACC, room 221   tel 351+226078830, ext 121
>  A M A D O   Rua Campo Alegre, 823         fax 351+226003654
>  A L V E S   P-4150 PORTO, Portugal        mob 351+939354002
> 
> 
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
> 




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-25 14:09 M. A. Alves
  2001-09-25 13:05 ` chris.danx
  2001-09-25 13:07 ` Jacob Sparre Andersen
@ 2001-09-25 13:37 ` Sergey Koshcheyev
  2 siblings, 0 replies; 22+ messages in thread
From: Sergey Koshcheyev @ 2001-09-25 13:37 UTC (permalink / raw)



"M. A. Alves" <maa@liacc.up.pt> wrote in message
news:mailman.1001419228.11962.comp.lang.ada@ada.eu.org...
> or... The Meanings of "Pure"
>
> Sergey Koshcheyev wrote:
> > I don't know exactly what you [Marin Condic] mean by "pure" x86 code.
> > What you get from the compiler on x86 is a 32-bit executable in the
> > platform-specific executable format (ELF on Linux, PE on Win32)
>
> You man the _target_ platform? (If so then code not pure.)

Well, GNAT has to generate the object files in *some* format, and unless you
have a cross-compiling version, it'll be ELF on Linux and PE (COFF) on
Win32. After that, you can use for example objcopy to transform the
generated format to some other, including plain binary (not tested, might
require linking the complete executable first or might not be possible at
all) - that's what you seem to call pure code, however when writing an OS
for x86, plain binary format isn't that useful.

> > which isn't linked to GNAT libraries, though I think it may be linked
> > dynamically to the C library. Linker switch -nostdlib can be used to
> > overcome this and get a completely stand-alone executable (tested on
> > Linux). Another linker switch can be used to link the C library in
> > statically (also tested on Linux).
>
> You mean _compiled_ on Linux or _executed_ on Linux? (If the latter then
> code not pure.)

I did all my testing in Linux. Any file in ELF format can be executed in
Linux, except if it's an OS it will crash at the first privileged
instruction, and probably even earlier.
Grub is a bootloader that, among other features, can switch to protected
mode, load an OS kernel in ELF format from disk, and run it. The OS then has
to do things like setting up descriptor tables, etc. You can of course write
your own bootloader and use your own format for the kernel image (binary,
for example), but it's easier to just use grub and make your OS kernel an
ELF executable.

> But note that for OS execution it would be acceptable to depend on the
> BIOS (at least early on the startup process); after all the BIOS is there
> and it is running before the OS.  *** But it is not acceptable at all for
> execution to depend on another OS. ***

GNAT assumes a 32bit environment which implies protected mode on x86, so
BIOS isn't accessible. You can still use machine code insertions to do
things that you can't do in Ada, or link to some assembly routines. The
execution of the no-run-time program does not depend on the OS - GNAT
doesn't itself generate code to do system calls, you can't use Text_IO or
threads from such program, and so on.

> In fact, I have been thinking in terms of a MIOS (Minimal Input/Output
> System) package providing access to the "minimal system" I have suggested
> before (Ada_OS talk) as a starting target (floppy, keyboard, screen): MIOS
> would probably be implemented with BIOS services: hence, in part, the
> tribute in its name.

Well, it's getting slightly off-topic, but writing a keyboard and a screen
driver isn't hard, floppy driver is harder. I have written a tiny OS kernel
in Ada myself as a university project, after it gets graded (in a few days),
I can make it available, if there is interest. It has a simple keyboard and
screen driver, no floppy driver and minimal support for threads and
pre-emptive scheduling (though not using the Ada language constructs).

> BTW, what is GRUB?  And where is GNORT?

GRUB - GRand Unified Bootloader, http://www.gnu.org/software/grub/
GNORT stands (stood) for Gnat NO Run Time, now it's called something like
GNAT Pro High Integrity edition, I think. It's a product that ACT sells. I
don't know what it contains, maybe somebody who knows can provide pointers
or information about it.

Any corrections to what I wrote above are welcome.

Sergey Koshcheyev

> Thanks,
>
> --
>    ,
>  M A R I O   data miner, LIACC, room 221   tel 351+226078830, ext 121
>  A M A D O   Rua Campo Alegre, 823         fax 351+226003654
>  A L V E S   P-4150 PORTO, Portugal        mob 351+939354002






^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-25  7:32     ` Sergey Koshcheyev
@ 2001-09-25 14:00       ` Marin David Condic
  2001-09-25 14:14         ` Lutz Donnerhacke
  2001-09-25 15:20         ` Sergey Koshcheyev
  0 siblings, 2 replies; 22+ messages in thread
From: Marin David Condic @ 2001-09-25 14:00 UTC (permalink / raw)


"Sergey Koshcheyev" <serko84@hotmail.com> wrote in message
news:9opbv7$1vg1$1@ns.felk.cvut.cz...
>
> While I was doing a web search to find out what you meant (I think I
> understand the idiom now), I found several webpages providing Round Tuits
to
> people who need them :-)
>
Sorry. Kind of an American-English-ism that I should have realized might not
be obvious to a more international croud. Nevertheless, you seem to have
figured it out, so we're O.K. :-)


>
> I don't know exactly what you mean by "pure" x86 code. What you get from
the
> compiler on x86 is a 32-bit executable in the platform-specific executable
> format (ELF on Linux, PE on Win32) which isn't linked to GNAT libraries,
> though I think it may be linked dynamically to the C library. Linker
> switch -nostdlib can be used to overcome this and get a completely
> stand-alone executable (tested on Linux). Another linker switch can be
used
> to link the C library in statically (also tested on Linux). GNAT doesn't
> insert any BIOS calls in the generated code when pragma No_Run_Time is
used.
>
What I mean by "pure" (probably a misuse since the term usually refers to
reentrant code) is that what I would like as output is a collection of
instructions that rely only on the Intel x86 processor. (Or, if one were
targeting MIPS, PowerPC, whatever,... instructions for that particular
target processor) If I understand the PC architecture correctly, code can be
generated that will create interrupts that the BIOS will pick up and utilize
as a kind of subroutine - the ISR accomplishing some kind of I/O operation,
etc. If one is saying "Well, maybe I don't have a BIOS or I don't have this
particular BIOS - maybe I've just got an Intel processor with some
specialized hardware & I want to make code that doesn't assume any BIOS or
OS or DLLs or anything..." then the question is will the compiler make
appropriate code that (after passage through the correct linker, etc.) can
run on such a machine?

I suppose what I'm wondering is can the use of the No_Run_Time pragma cause
the Gnat compiler to be suitable as an embedded compiler? It doesn't matter
if you don't get full-up Ada - just that you get embeddable code or compiler
errors for any feature that might not be embeddable. (I can live with a
subset of Ada if the compiler tells me when I can't do something.)
Presumably, one could then implement the low-level operations needed by
full-up Ada (create your own runtime) so long as you could find out what
mechanisms the compiler used to get the required services from its own
runtime.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/






^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-25  7:43   ` Peter Amey
@ 2001-09-25 14:02     ` Marin David Condic
  0 siblings, 0 replies; 22+ messages in thread
From: Marin David Condic @ 2001-09-25 14:02 UTC (permalink / raw)


Thanks. I've got that link saved now too.

MDC

--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"Peter Amey" <peter.amey@praxis-cs.co.uk> wrote in message
news:3BB035B1.F4ABF4A0@praxis-cs.co.uk...
> [snip]
> > linked that in statically.
> >
> > Serge Robyns has written a small OS kernel using GNAT and pragma
No_Run_Time
> > this way. It can be found at http://web.wanadoo.be/rc.s/AdaOS/index.html
>
> You might also like to take a look at: "Re-engineering a safety-critical
> system with SPARK95 and GNORT" under "Publications" at www.sparkada.com
>
>
> Peter
>
> --
> --------------------------------------------------------------------------
-
>       __         Peter Amey, Product Manager
>         )                    Praxis Critical Systems Ltd
>        /                     20, Manvers Street, Bath, BA1 1PX
>       / 0        Tel: +44 (0)1225 466991
>      (_/         Fax: +44 (0)1225 469006
>                  http://www.praxis-cs.co.uk/
>
> --------------------------------------------------------------------------





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
@ 2001-09-25 14:09 M. A. Alves
  2001-09-25 13:05 ` chris.danx
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: M. A. Alves @ 2001-09-25 14:09 UTC (permalink / raw)
  To: comp.lang.ada

or... The Meanings of "Pure"

Sergey Koshcheyev wrote:
> I don't know exactly what you [Marin Condic] mean by "pure" x86 code.
> What you get from the compiler on x86 is a 32-bit executable in the
> platform-specific executable format (ELF on Linux, PE on Win32)

You man the _target_ platform? (If so then code not pure.)

> which isn't linked to GNAT libraries, though I think it may be linked
> dynamically to the C library. Linker switch -nostdlib can be used to
> overcome this and get a completely stand-alone executable (tested on
> Linux). Another linker switch can be used to link the C library in
> statically (also tested on Linux).

You mean _compiled_ on Linux or _executed_ on Linux? (If the latter then
code not pure.)

> GNAT doesn't insert any BIOS calls in the generated code when pragma
> No_Run_Time is used.

Good.

But note that for OS execution it would be acceptable to depend on the
BIOS (at least early on the startup process); after all the BIOS is there
and it is running before the OS.  *** But it is not acceptable at all for
execution to depend on another OS. ***

In fact, I have been thinking in terms of a MIOS (Minimal Input/Output
System) package providing access to the "minimal system" I have suggested
before (Ada_OS talk) as a starting target (floppy, keyboard, screen): MIOS
would probably be implemented with BIOS services: hence, in part, the
tribute in its name.

BTW, what is GRUB?  And where is GNORT?

Thanks,

-- 
   ,
 M A R I O   data miner, LIACC, room 221   tel 351+226078830, ext 121
 A M A D O   Rua Campo Alegre, 823         fax 351+226003654
 A L V E S   P-4150 PORTO, Portugal        mob 351+939354002





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-25 14:00       ` Marin David Condic
@ 2001-09-25 14:14         ` Lutz Donnerhacke
  2001-09-25 19:40           ` Robert Dewar
  2001-09-25 15:20         ` Sergey Koshcheyev
  1 sibling, 1 reply; 22+ messages in thread
From: Lutz Donnerhacke @ 2001-09-25 14:14 UTC (permalink / raw)


* Marin David Condic wrote:
>I suppose what I'm wondering is can the use of the No_Run_Time pragma cause
>the Gnat compiler to be suitable as an embedded compiler?

No. That's not the purpose of No_Run_Time. It is used to prevent the
injection of unnecessary compiler generated code (especially code containing
decisions) in order to ease software verification (path coverage tests).

For embedded enviroments, all you have to do is linking against a
approbriate library instead of stdlibc. This is a compiler flag to the linker.

$ cat t.adb
with Ada.Text_IO;
use Ada.Text_IO;

procedure t is
begin
   Put_Line ("Hello world.");
end t;
$ gnatmake t -largs -nostdlib
ld: warning: cannot find entry symbol _start; defaulting to 08048074
.../adalib/libgnat.a(a-except.o): In function ada__exceptions__address_image':
  .../rts/a-except.adb:309: undefined reference to memcpy'
...

Have fun.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
       [not found] <Pine.LNX.4.33.0109251630310.3066-100000@lagoa.niaad.liacc.up.pt>
@ 2001-09-25 14:48 ` Samuel Tardieu
  0 siblings, 0 replies; 22+ messages in thread
From: Samuel Tardieu @ 2001-09-25 14:48 UTC (permalink / raw)
  To: comp.lang.ada

On 25/09, M. A. Alves wrote:
| The Meanings of "Pure" II
| 
| Sergey wrote:
| > Well, GNAT has to generate the object files in *some* format, and
| > unless you have a cross-compiling version, it'll be ELF on Linux and
| > PE (COFF) on Win32.
| 
| You mean there is no plain x86 code?  A simple sequence of machine code
| instructions?  "Pure" code?

Plain old x86 code implies that you have no symbol stored in the object file.
One of the consequence is that you cannot link different object files
together and have references resolved.

GNAT generates assembly code, which is then assembled and linked. If you want
to use GNAT in bare-board mode and get a file that you can for example put
into a eprom, you can convert any decent format (ELF, coff, ...) to srec
or plain binary.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-25 16:49 M. A. Alves
@ 2001-09-25 15:05 ` chris.danx
  2001-09-25 15:38   ` Marin David Condic
  0 siblings, 1 reply; 22+ messages in thread
From: chris.danx @ 2001-09-25 15:05 UTC (permalink / raw)



"M. A. Alves" <maa@liacc.up.pt> wrote in message
news:mailman.1001428823.15394.comp.lang.ada@ada.eu.org...
> The Meanings of "Pure" II
>
> Sergey wrote:
> > Well, GNAT has to generate the object files in *some* format, and
> > unless you have a cross-compiling version, it'll be ELF on Linux and
> > PE (COFF) on Win32.
>
> You mean there is no plain x86 code?  A simple sequence of machine code
> instructions?  "Pure" code?

Pure code being that which does not contain interrupts/os calls?  Or pure in
the sense that it is not in an object file?  Or that which is not protected
mode code?

> Is the good old Van Neuman architecture at risk?

Why would it be?  Von Neuman may die due to something like CA-effectant
computers (which would be ironic) or the RAW architecture but they're
immature.  Object files do not present a threat to Von Neumann machines, in
fact they're part of why it's so popular (they make things easier, hence
aiding popularity).


> (I am no guru with object code formats, but there must be a neutral one,
> with no "brand" on it (except the processor's).  I assume ELF or PE or
> COFF is not such a thing, or else this discussion is meaningless.)

No.  You misunderstand the function of an object file.  It's intended to
provide a structure to a file, and contains information that allows a linker
or loader to locate routines.  All formats are technically neutral, it's
just that on windows COFF is used more than ELF and on Linux the reverse.

> Personally for the hobby OS in Ada I am only interested in a "pure"
> approach.  No fancy loaders, no branded formats, in sum no dependencies:
> pure = truly free.

I suppose you could get a bootstrap to load a plain binary file, but you'd
still need to compile to ELF on Linux, or COFF on windows and link your
modules together into the plain format.  However the problem is that it
removes structure from the file and *could* complicate matters later.


I really don't understand what you mean by "pure" or why Object File Formats
 are so bad.



Chris






^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-25 14:00       ` Marin David Condic
  2001-09-25 14:14         ` Lutz Donnerhacke
@ 2001-09-25 15:20         ` Sergey Koshcheyev
  1 sibling, 0 replies; 22+ messages in thread
From: Sergey Koshcheyev @ 2001-09-25 15:20 UTC (permalink / raw)



"Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org> wrote in
message news:9oq2mf$9as$1@nh.pace.co.uk...
> "Sergey Koshcheyev" <serko84@hotmail.com> wrote in message
> news:9opbv7$1vg1$1@ns.felk.cvut.cz...
>
> What I mean by "pure" (probably a misuse since the term usually refers to
> reentrant code) is that what I would like as output is a collection of
> instructions that rely only on the Intel x86 processor. (Or, if one were
> targeting MIPS, PowerPC, whatever,... instructions for that particular
> target processor) If I understand the PC architecture correctly, code can
be
> generated that will create interrupts that the BIOS will pick up and
utilize
> as a kind of subroutine - the ISR accomplishing some kind of I/O
operation,
> etc. If one is saying "Well, maybe I don't have a BIOS or I don't have
this
> particular BIOS - maybe I've just got an Intel processor with some
> specialized hardware & I want to make code that doesn't assume any BIOS or
> OS or DLLs or anything..." then the question is will the compiler make
> appropriate code that (after passage through the correct linker, etc.) can
> run on such a machine?

The answer is "yes, but..." :-)

If you use pragma No_Run_Time, GNAT won't use runtime features implicitly
(most importantly, tasking, and except probably using memcpy to copy
arrays). It kind of brings Ada closer to C by cutting off features. But you
can, for example, explicitly use dynamic allocation. GNAT won't use BIOS,
since it neither has any reason to (it doesn't do any I/O), nor any
knowledge how to use it.

To compile a completely stand-alone program on Linux (my little OS kernel),
I use pragma No_Run_Time, -nostdlib -static flags for gnatbind,
and -nostdlib -static -lc (link with C library statically, because of the
memcpy thing mentioned above) flags for gnatlink. This way I get an
executable in ELF format that can be booted into using grub, but nothing
ties it to the OS (i.e. it does no system calls) nor does it use any DLLs.

One thing I'm not so sure about, though, are predefined exceptions, most
importantly Constraint_Error. I think that GNAT calls a function named
something like __gnat_raise_constraint_error when it needs to raise it, and
you can (or even most probably have to) redefine that function. Or you can
use pragma No_Exceptions or -gnatp flag to eliminate that worry also.

Also, in your example, you will have to somehow ensure that the processor is
in 32bit flat mode prior to executing Ada code, but that's a minor point.

> I suppose what I'm wondering is can the use of the No_Run_Time pragma
cause
> the Gnat compiler to be suitable as an embedded compiler? It doesn't
matter
> if you don't get full-up Ada - just that you get embeddable code or
compiler
> errors for any feature that might not be embeddable. (I can live with a
> subset of Ada if the compiler tells me when I can't do something.)
> Presumably, one could then implement the low-level operations needed by
> full-up Ada (create your own runtime) so long as you could find out what
> mechanisms the compiler used to get the required services from its own
> runtime.

I don't have any experience with embedded devices, so I can't tell. The
compiler does output an error message if you use a forbidden feature.

Once again, any corrections are welcome, since everything I said above is
based only on my personal experiences and I don't already remember
everything exactly.

Sergey Koshcheyev.

>
> MDC
> --
> Marin David Condic
> Senior Software Engineer
> Pace Micro Technology Americas    www.pacemicro.com
> Enabling the digital revolution
> e-Mail:    marin.condic@pacemicro.com
> Web:      http://www.mcondic.com/





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-25 15:05 ` chris.danx
@ 2001-09-25 15:38   ` Marin David Condic
  0 siblings, 0 replies; 22+ messages in thread
From: Marin David Condic @ 2001-09-25 15:38 UTC (permalink / raw)


I never should have used the word "Pure"! :-)

There's one possibility for "Pure" which (at least it used to) refers to
reentrant code. Then there seems to be some usage of it here to mean what
used to be called "Absolute" code - code in which all of the addresses have
been resolved to some physical (or logical, in the case of machines that do
some form of memory-mapping/page table management) address. Then there's the
kind of code I was interested in - code that may be full of relocatable
addresses and may not even be reentrant, but after passing through some
appropriate linker/loader, ends up containing no calls to an OS or DLLs or
runtime that wasn't supplied explicitly to the linker or interrupts to a
BIOS that may or may not exist, etc. IOW, machine instructions that will run
without any other assumptions about what else may be available beyond the
target processor.

I don't know what term people might use to describe that sort of code
generation, but I was interested in code generation that did not make any
calls or traps to an environment that may not be there. I don't know if the
pragma No_Run_Time accomplishes this or not - or if it works the same way
for all targets. I'm hearing that this was not the intended use of the
pragma (which I understand) but I was wondering if it was a useful side
effect.

What everyone else is interested in, I could only speculate on, but I hope
this serves to clarify the terminology a little.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"chris.danx" <chris.danx@ntlworld.com> wrote in message
news:j31s7.2446$L4.520357@news6-win.server.ntlworld.com...
>
> "M. A. Alves" <maa@liacc.up.pt> wrote in message
> news:mailman.1001428823.15394.comp.lang.ada@ada.eu.org...
> > The Meanings of "Pure" II
> >
> > Sergey wrote:
> > > Well, GNAT has to generate the object files in *some* format, and
> > > unless you have a cross-compiling version, it'll be ELF on Linux and
> > > PE (COFF) on Win32.
> >
> > You mean there is no plain x86 code?  A simple sequence of machine code
> > instructions?  "Pure" code?
>
> Pure code being that which does not contain interrupts/os calls?  Or pure
in
> the sense that it is not in an object file?  Or that which is not
protected
> mode code?
>
> > Is the good old Van Neuman architecture at risk?
>
> Why would it be?  Von Neuman may die due to something like CA-effectant
> computers (which would be ironic) or the RAW architecture but they're
> immature.  Object files do not present a threat to Von Neumann machines,
in
> fact they're part of why it's so popular (they make things easier, hence
> aiding popularity).
>
>
> > (I am no guru with object code formats, but there must be a neutral one,
> > with no "brand" on it (except the processor's).  I assume ELF or PE or
> > COFF is not such a thing, or else this discussion is meaningless.)
>
> No.  You misunderstand the function of an object file.  It's intended to
> provide a structure to a file, and contains information that allows a
linker
> or loader to locate routines.  All formats are technically neutral, it's
> just that on windows COFF is used more than ELF and on Linux the reverse.
>
> > Personally for the hobby OS in Ada I am only interested in a "pure"
> > approach.  No fancy loaders, no branded formats, in sum no dependencies:
> > pure = truly free.
>
> I suppose you could get a bootstrap to load a plain binary file, but you'd
> still need to compile to ELF on Linux, or COFF on windows and link your
> modules together into the plain format.  However the problem is that it
> removes structure from the file and *could* complicate matters later.
>
>
> I really don't understand what you mean by "pure" or why Object File
Formats
>  are so bad.
>
>
>
> Chris
>
>
>





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
@ 2001-09-25 16:49 M. A. Alves
  2001-09-25 15:05 ` chris.danx
  0 siblings, 1 reply; 22+ messages in thread
From: M. A. Alves @ 2001-09-25 16:49 UTC (permalink / raw)
  To: comp.lang.ada

The Meanings of "Pure" II

Sergey wrote:
> Well, GNAT has to generate the object files in *some* format, and
> unless you have a cross-compiling version, it'll be ELF on Linux and
> PE (COFF) on Win32.

You mean there is no plain x86 code?  A simple sequence of machine code
instructions?  "Pure" code?

Is the good old Van Neuman architecture at risk?

(I am no guru with object code formats, but there must be a neutral one,
with no "brand" on it (except the processor's).  I assume ELF or PE or
COFF is not such a thing, or else this discussion is meaningless.)

Personally for the hobby OS in Ada I am only interested in a "pure"
approach.  No fancy loaders, no branded formats, in sum no dependencies:
pure = truly free.

Cheers,

-- 
   ,
 M A R I O   data miner, LIACC, room 221   tel 351+226078830, ext 121
 A M A D O   Rua Campo Alegre, 823         fax 351+226003654
 A L V E S   P-4150 PORTO, Portugal        mob 351+939354002





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
@ 2001-09-25 17:07 M. A. Alves
  0 siblings, 0 replies; 22+ messages in thread
From: M. A. Alves @ 2001-09-25 17:07 UTC (permalink / raw)
  To: comp.lang.ada

Samuel Tardieu wrote:
> . . . If you want to use GNAT in bare-board mode and get a file that
> you can for example put into a eprom

or a boot sector...

> you can convert any decent format (ELF, coff, ...) to srec or plain
> binary.

Thanks, all is clear now.

-- 
   ,
 M A R I O   data miner, LIACC, room 221   tel 351+226078830, ext 121
 A M A D O   Rua Campo Alegre, 823         fax 351+226003654
 A L V E S   P-4150 PORTO, Portugal        mob 351+939354002





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-25 14:14         ` Lutz Donnerhacke
@ 2001-09-25 19:40           ` Robert Dewar
  2001-09-26  9:04             ` Lutz Donnerhacke
  0 siblings, 1 reply; 22+ messages in thread
From: Robert Dewar @ 2001-09-25 19:40 UTC (permalink / raw)


lutz@iks-jena.de (Lutz Donnerhacke) wrote in message news:<slrn9r14aj.i8.lutz@taranis.iks-jena.de>...

> No. That's not the purpose of No_Run_Time. It is used to > prevent the
> injection of unnecessary compiler generated code 
> (especially code containing
> decisions) in order to ease software verification (path 
> coverage tests).

The above is completely incorrect, it has no such effect.
I am guessing that you are mixing this up with
pragma Restrictions (No_Implicit_Conditionals).



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Curiousity: pragma No_Run_Time for Gnat
  2001-09-25 19:40           ` Robert Dewar
@ 2001-09-26  9:04             ` Lutz Donnerhacke
  0 siblings, 0 replies; 22+ messages in thread
From: Lutz Donnerhacke @ 2001-09-26  9:04 UTC (permalink / raw)


* Robert Dewar wrote:
>lutz@iks-jena.de (Lutz Donnerhacke) wrote in message news:<slrn9r14aj.i8.lutz@taranis.iks-jena.de>...
>> No. That's not the purpose of No_Run_Time. It is used to prevent the
>> injection of unnecessary compiler generated code (especially code
>> containing decisions) in order to ease software verification (path
>> coverage tests).
>
>The above is completely incorrect, it has no such effect.

I only tried to follow a 1996 discussion at google about GNORT.
The statement above was constructed mostly from reading postings of Robert
Dewar.

>I am guessing that you are mixing this up with pragma Restrictions
>(No_Implicit_Conditionals).

It might be changed. But more probably I did not get it.



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2001-09-26  9:04 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Pine.LNX.4.33.0109251630310.3066-100000@lagoa.niaad.liacc.up.pt>
2001-09-25 14:48 ` Curiousity: pragma No_Run_Time for Gnat Samuel Tardieu
2001-09-25 17:07 M. A. Alves
  -- strict thread matches above, loose matches on Subject: below --
2001-09-25 16:49 M. A. Alves
2001-09-25 15:05 ` chris.danx
2001-09-25 15:38   ` Marin David Condic
2001-09-25 14:09 M. A. Alves
2001-09-25 13:05 ` chris.danx
2001-09-25 13:07 ` Jacob Sparre Andersen
2001-09-25 13:37 ` Sergey Koshcheyev
     [not found] <Pine.LNX.4.33.0109251343310.2841-100000@lagoa.niaad.liacc.up.pt>
2001-09-25 13:20 ` David C. Hoos
2001-09-24 19:02 Marin David Condic
2001-09-24 21:14 ` Sergey Koshcheyev
2001-09-24 21:54   ` Marin David Condic
2001-09-25  7:32     ` Sergey Koshcheyev
2001-09-25 14:00       ` Marin David Condic
2001-09-25 14:14         ` Lutz Donnerhacke
2001-09-25 19:40           ` Robert Dewar
2001-09-26  9:04             ` Lutz Donnerhacke
2001-09-25 15:20         ` Sergey Koshcheyev
2001-09-25  7:36     ` Jean-Marc Bourguet
2001-09-25  7:43   ` Peter Amey
2001-09-25 14:02     ` Marin David Condic

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