comp.lang.ada
 help / color / mirror / Atom feed
From: anon@att.net
Subject: Re: Bootstrapping a null procedure. Seriously?!
Date: Wed, 13 Mar 2013 04:34:16 +0000 (UTC)
Date: 2013-03-13T04:34:16+00:00	[thread overview]
Message-ID: <khovk7$71r$1@speranza.aioe.org> (raw)
In-Reply-To: 19d330ec-9b61-414e-abc3-e25a8c786b81@googlegroups.com


To compile a barebone Ada program you must not use "gnatmake" 
or "gnat make" because it auto execute the Ada binder "gnatbind" 
and the "gnat linker". Gnat's binder and linker can not be used 
because they creates an os bound program. And they also adds a 
number of simple routines that may not be required for your 
program.

Any and all subunits and libraries that requires elaboration must 
be done manually first, within the main program. Normally this job 
is handled by the Gnat binder. The elaboration code can be in cased 
within a procedure or function that is called by the main program.

Also, you can not use the standard "raise" statement or the 
standard exception handlers. For exceptions to work, Gnat
compiler requires a number of System packages be load as well 
as "Ada.Exceptions". 


# --
# --  Makefile
# --
gnat compile testnulmain.adb
#
#  use -nostdinclib to remove most of gcc standard libraries
#      but os startup code is included from "libc".
#  additional libraries files, if included must be added to 
#  the command line.
#  
#  To reduce code to the basic user created only code use the
#   -T <file> command. The file defines ".text", ".data", 
#  ".rodata", and ".bss" setions and then discard all other 
#  sections.
#
#  Note: use -o testnulmain.exe for all microsoft based os(s)
#        gcc only support ".com" files with the -T <file> option
#
gcc -nostdinclib -o testnulmain testnulmain.o


--
--  testnulmain.ads
--
procedure testnulmain ;
  --
  --  Required by linker
  --
  pragma Export ( Ada, testnulmain, "main" ) ;


--
--  testnulmain.adb
--
--    Can include "Stand-Alone" Ada packages, like Ada.Characters,
--    Ada.Interfaces, or System. Actually any Ada library that 
--    does not require direct or indirect OS linking can be used.
--
with System ;
procedure TestNulMain is

  --
  --  In this example System.o is not needed to link file
  --
  TestVar : System.Address := System.Null_Address ;

begin

  --  preform elaboration here first

  null ;
end TestNulMain ;


In <19d330ec-9b61-414e-abc3-e25a8c786b81@googlegroups.com>, Diogenes <phathax0r@gmail.com> writes:
>I've been doing some binder experiments with this little gem....
>
>procedure nullmain is
>
>begin
>
>  null;
>
>end nullmain;
>
>
>Been doing it to see just how many packages from the runtime have to be lin=
>ked in order for the the thing to DO NOTHING!
>
>40 packages are pulled in.
>
>By most measures of good software design, this is WRONG.
>
>So here's the question...
>
>Do I need to have different a-finali.ads/.adb packages and the correspondin=
>g crt1.o implementations for every possible variation on the runtime I coul=
>d ever want? I mean, seriously, it's pulling in system.string_opts; does an=
>yone see strings in the above code?
>
>Of course I realize this is partly due to package dependency issues, howeve=
>r I SHOULD be able to write my own a-finali.ads that does nothing but make =
>a _start symbol for the system linker, right?
>
>Tips?
>




  parent reply	other threads:[~2013-03-13  4:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-11 10:37 Bootstrapping a null procedure. Seriously?! Diogenes
2013-03-11 11:26 ` Georg Bauhaus
2013-03-11 21:14   ` Diogenes
2013-03-11 22:39     ` Robert A Duff
2013-03-12 12:09     ` Brian Drummond
2013-03-12 14:04       ` Diogenes
2013-03-13 22:32         ` Brian Drummond
2013-03-11 22:24   ` Randy Brukardt
2013-03-13  4:34 ` anon [this message]
2013-04-01 16:21 ` Oliver Kleinke
replies disabled

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