comp.lang.ada
 help / color / mirror / Atom feed
* Strip procedure prologue and epilogue
@ 2008-12-16 22:52 pini
  2008-12-16 23:06 ` Ludovic Brenta
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: pini @ 2008-12-16 22:52 UTC (permalink / raw)


A usual procedure like

procedure Foo
begin
  -- some stuff here;
end;

generates a prologue like

pushl %ebx
-- generated code for some stuff here
popl %ebx

I have a very specific procedure whose purpose is to be called at
bootloading time and set up a stack, so there is no need for the
prologue and epilogue of this procedure to exist.
Is there an ada-only way (through a pragma for instance) to strip the
prologue and epilogue of this procedure ?

Any help is welcome.

pini



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

* Re: Strip procedure prologue and epilogue
  2008-12-16 22:52 Strip procedure prologue and epilogue pini
@ 2008-12-16 23:06 ` Ludovic Brenta
  2008-12-17  0:01 ` Jeffrey R. Carter
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Ludovic Brenta @ 2008-12-16 23:06 UTC (permalink / raw)


On Dec 16, 11:52 pm, pini <zep...@gmail.com> wrote:
> A usual procedure like
>
> procedure Foo
> begin
>   -- some stuff here;
> end;
>
> generates a prologue like
>
> pushl %ebx
> -- generated code for some stuff here
> popl %ebx
>
> I have a very specific procedure whose purpose is to be called at
> bootloading time and set up a stack, so there is no need for the
> prologue and epilogue of this procedure to exist.
> Is there an ada-only way (through a pragma for instance) to strip the
> prologue and epilogue of this procedure ?
>
> Any help is welcome.

I'm not an expert in this matter but maybe you should look at how
Lovelace boots. The source is in the public monotone server I just
mentioned and there's a snapshot at
http://people.debian.org/~lbrenta/org.os-lovelace-2008-07-02T21:01:02.tar.gz

More info about Lovelace on http://www.lovelace.fr

HTH

--
Ludovic Brenta.



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

* Re: Strip procedure prologue and epilogue
  2008-12-16 22:52 Strip procedure prologue and epilogue pini
  2008-12-16 23:06 ` Ludovic Brenta
@ 2008-12-17  0:01 ` Jeffrey R. Carter
  2008-12-17  8:11 ` Rolf
  2008-12-19  0:01 ` Samuel Tardieu
  3 siblings, 0 replies; 7+ messages in thread
From: Jeffrey R. Carter @ 2008-12-17  0:01 UTC (permalink / raw)


pini wrote:
> 
> pushl %ebx
> -- generated code for some stuff here
> popl %ebx
> 
> I have a very specific procedure whose purpose is to be called at
> bootloading time and set up a stack, so there is no need for the
> prologue and epilogue of this procedure to exist.
> Is there an ada-only way (through a pragma for instance) to strip the
> prologue and epilogue of this procedure ?

If you require specific machine code, you should use a machine-code insertion.

-- 
Jeff Carter
"I like it when the support group complains that they have
insufficient data on mean time to repair bugs in Ada software."
Robert I. Eachus
91



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

* Re: Strip procedure prologue and epilogue
  2008-12-16 22:52 Strip procedure prologue and epilogue pini
  2008-12-16 23:06 ` Ludovic Brenta
  2008-12-17  0:01 ` Jeffrey R. Carter
@ 2008-12-17  8:11 ` Rolf
  2008-12-17  9:40   ` pini
  2008-12-19  0:01 ` Samuel Tardieu
  3 siblings, 1 reply; 7+ messages in thread
From: Rolf @ 2008-12-17  8:11 UTC (permalink / raw)


On Dec 16, 11:52 pm, pini <zep...@gmail.com> wrote:
> A usual procedure like
>
> procedure Foo
> begin
>   -- some stuff here;
> end;
>
> generates a prologue like
>
> pushl %ebx
> -- generated code for some stuff here
> popl %ebx
>
> I have a very specific procedure whose purpose is to be called at
> bootloading time and set up a stack, so there is no need for the
> prologue and epilogue of this procedure to exist.
> Is there an ada-only way (through a pragma for instance) to strip the
> prologue and epilogue of this procedure ?
>
> Any help is welcome.

There is no general Ada solution for that, but a GNAT specific
pragma.  Gcc provides the attribute "naked" for some back-ends.  It is
used like this:

procedure Foo;
pragma Machine_Attribute (Entity         => Foo,
                          Attribute_Name => "naked");

The pragma is intended for start-up code like initialising some RAM
area or for writing your own task switching code.

Be very careful here and inspect the generated assembler code.  Naked
procedures will not only omit the prologue and epilogue but also the
ret statemant. You typically must not use any code that requires
support from the run time system at that stage.

   Rolf




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

* Re: Strip procedure prologue and epilogue
  2008-12-17  8:11 ` Rolf
@ 2008-12-17  9:40   ` pini
  2008-12-17  9:50     ` Ludovic Brenta
  0 siblings, 1 reply; 7+ messages in thread
From: pini @ 2008-12-17  9:40 UTC (permalink / raw)


@Jeffrey & @Rolf : I was looking for something like that, but
unfortunately gcc doesn't support the naked attribute on x86 (and
probably never will, as it is considered harmful by gcc developers).

@Ludovic : Thanks for the link. I already heard of Lovelace (even had
a phone discussion with Xavier Grave), but last time I checked (i.e. 2
seconds ago :), the link to source code on lovelace.fr was dead, so
thank you for your link to the monotone snapshot, I'm currently having
a look at it.

Regards,

pini



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

* Re: Strip procedure prologue and epilogue
  2008-12-17  9:40   ` pini
@ 2008-12-17  9:50     ` Ludovic Brenta
  0 siblings, 0 replies; 7+ messages in thread
From: Ludovic Brenta @ 2008-12-17  9:50 UTC (permalink / raw)


On Dec 17, 10:40 am, pini wrote on comp.lang.ada:
> @Ludovic : Thanks for the link. I already heard of Lovelace (even had
> a phone discussion with Xavier Grave), but last time I checked (i.e. 2
> seconds ago :), the link to source code on lovelace.fr was dead, so
> thank you for your link to the monotone snapshot, I'm currently having
> a look at it.

The link points to the viewmtn web interface to the monotone server.
As I explained earlier, the monotone server is back up and running but
the web interface is not.

--
Ludovic Brenta.
Registered Linux user #6891: http://counter.li.org



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

* Re: Strip procedure prologue and epilogue
  2008-12-16 22:52 Strip procedure prologue and epilogue pini
                   ` (2 preceding siblings ...)
  2008-12-17  8:11 ` Rolf
@ 2008-12-19  0:01 ` Samuel Tardieu
  3 siblings, 0 replies; 7+ messages in thread
From: Samuel Tardieu @ 2008-12-19  0:01 UTC (permalink / raw)


>>>>> "pini" == pini  <zepini@gmail.com> writes:

pini> I have a very specific procedure whose purpose is to be called
pini> at bootloading time and set up a stack, so there is no need for
pini> the prologue and epilogue of this procedure to exist.  Is there
pini> an ada-only way (through a pragma for instance) to strip the
pini> prologue and epilogue of this procedure ?

Probably not, as the existence of the prologue/epilogue is not
supposed to change anything for the Ada programmer.

If you're using GNAT, you may be lucky by using
"-fomit-frame-pointer" on your code.

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/



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

end of thread, other threads:[~2008-12-19  0:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-16 22:52 Strip procedure prologue and epilogue pini
2008-12-16 23:06 ` Ludovic Brenta
2008-12-17  0:01 ` Jeffrey R. Carter
2008-12-17  8:11 ` Rolf
2008-12-17  9:40   ` pini
2008-12-17  9:50     ` Ludovic Brenta
2008-12-19  0:01 ` Samuel Tardieu

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