comp.lang.ada
 help / color / mirror / Atom feed
* GNAT and no runtime
@ 2004-05-25 20:57 JCS
  2004-05-26  7:46 ` Rolf Ebert
                   ` (2 more replies)
  0 siblings, 3 replies; 29+ messages in thread
From: JCS @ 2004-05-25 20:57 UTC (permalink / raw)


Hi,

I'm trying to create a toy-OS in Ada and I'm still in the very begining
yet.
The "kernel" can boot (with the help of GRUB), I can print a "Hello
world" text, and retrieve some informations from the bootloader.
Before going further, I would like to take advantage of Ada, so at least
use exceptions.

Obviously, the program can't use the GNAT library, and it is so not
linked with it. I also use the pragma No_Runtime, to be sure I'm not using
anything which would require the runtime.

So then, I enabled the checks, and the linker complained about the missing
"__gnat_last_chance_handler" reference. In the GNAT manual, there is a
small reference to this function but somewhat unclear in the
implementation defined characteristics section:
===========================================================
No_Exception_Handlers 
This restriction ensures at compile time that there are no explicit
exception handlers. It also indicates that no exception propagation will
be provided. In this mode, exceptions may be raised but will result in an
immediate call to the last chance handler, a routine that the user must
define with the following profile: 

procedure Last_Chance_Handler (Source_Location : System.Address; Line : Integer); pragma Export (C, Last_Chance_Handler, "__gnat_last_chance_handler"); 

The parameter is a C null-terminated string representing a message to be
associated with the exception (typically the source location of the raise
statement generated by the compiler). The Line parameter when non-zero
represents the line number in the source program where the raise occurs
===========================================================
OK, so I made this routine print a litle message and do an endless loop.
To test it, I put a "raise Constraint_Error;" in my main routine,
obviously without any handler for it.
It linked correctly, and it worked, except that Source_Location where
pointing to an empty string (but the line was correct).

Not so bad, so then I tried to define my own exception, still in my main
routine, I wrote sth like:
  procedure main is
    ...
    My_Error : exception;
  begin
    ...
    raise My_Error;
  end main;

But now, it refuses again to link. I got some undefined references,
mainly in the elaboration code. It wants to elaborate:
  Ada.Exceptions
  System.Exception_Table
  System.Exceptions
  System.Soft_Links
  System.Secondary_Stack
And in the main program, I get an undefined reference to
 Ada.Exceptions.Raise_Exception

I'm a bit surprised, why is it so different than with a predefined
exception?
I didn't think that exceptions need OS-specific functions...

Note also: when I use "pragma No_Return(main);", I get a warning with
My_Error and not with Constraint_Error: 
"main.adb:31: attention : `noreturn' function does return"
That seems stupid, the function does not return, doesn't it?!

So you probably guess my question: is there a solution?
Do I have to implement something?

Cheers,
JC



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

end of thread, other threads:[~2004-06-10  5:15 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-25 20:57 GNAT and no runtime JCS
2004-05-26  7:46 ` Rolf Ebert
2004-05-26 12:17   ` JCS
2004-05-28 15:13   ` JCS
2004-05-26 10:52 ` Wojtek Narczynski
2004-05-26 12:33   ` JCS
2004-05-26 16:05     ` Martin Krischik
2004-05-27  9:40       ` Wojtek Narczynski
2004-05-28 20:42       ` Wojtek Narczynski
2004-06-08  5:43         ` Martin Krischik
2004-06-09  5:07           ` Simon Wright
2004-06-09  6:22             ` Martin Krischik
2004-06-09  7:20               ` Martin Dowie
2004-06-09  7:52                 ` Martin Krischik
2004-06-09  9:26                   ` Martin Dowie
2004-06-09 11:50                     ` Martin Krischik
2004-06-10  5:15                       ` Simon Wright
2004-06-09 16:33             ` Robert I. Eachus
2004-05-27 10:23     ` Wojtek Narczynski
2004-05-27 12:45       ` JCS
2004-05-26 19:51   ` Georg Bauhaus
2004-05-27  9:43     ` Wojtek Narczynski
2004-05-26 16:44 ` sk
2004-05-26 17:42   ` JCS
2004-05-26 21:33     ` sk
2004-05-26 23:12       ` JCS
2004-05-27 13:58         ` sk
2004-05-27 21:30           ` JCS
2004-05-27 22:42             ` sk

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