comp.lang.ada
 help / color / mirror / Atom feed
* assembly generated using gcc -S on a .adb
@ 2002-07-08  2:55 KK
  2002-07-08  3:15 ` Jeffrey Carter
  2002-07-08  6:31 ` sk
  0 siblings, 2 replies; 3+ messages in thread
From: KK @ 2002-07-08  2:55 UTC (permalink / raw)


Could someone elucidate for me just why the assembly language file
generated by something like:

gcc -S test.adb

can't be further compiled when something like the following:

gcc test.s

is invoked?  I get the following errors:

/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'

Yet when I compile a c program similarly (first to asm then on to executable
as above) everything is fine.

I realize that gcc *is* a c compiler (among other things) and that the reference
to main in my error message probably has something to do with gcc thinking that
the asm it's trying to assemble was originally a c program.

I also can still see plenty of ada specific stuff in the header & footer of
test.s so there seems to be some indication that even at the level of asm there 
is still quite a bit of language specific stuff going on.  My question is why?
I would think that once you get to the level of asm all that kind of stuff would 
have necessarily fallen away.

BTW, I'm aware of gnatbind and gnatlink, and yes those do work and produce an
executable.  What I'm wondering is if there is a path to a working executable
without using those utilities.  In other words, is there a way for a machine
with just gcc installed, to produce an executable from an asm file that was 
generated from an .adb ??

If you're wondering why such a thing would matter to me, it's for a web project
wherein some assembly is generated and I'm looking for a way for someone to be 
able to finish the process on their own without having the whole GNAT system 
installed on their machine.

Thanks,

Rob



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

* Re: assembly generated using gcc -S on a .adb
  2002-07-08  2:55 assembly generated using gcc -S on a .adb KK
@ 2002-07-08  3:15 ` Jeffrey Carter
  2002-07-08  6:31 ` sk
  1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey Carter @ 2002-07-08  3:15 UTC (permalink / raw)


KK wrote:
> 
> BTW, I'm aware of gnatbind and gnatlink, and yes those do work and produce an
> executable.  What I'm wondering is if there is a path to a working executable
> without using those utilities.  In other words, is there a way for a machine
> with just gcc installed, to produce an executable from an asm file that was
> generated from an .adb ??

When you understand that gnatbind generates the main program, you will
probably understand why you can't simply assemble the assembler output
from GNAT to obtain a working program. Check the secret documentation to
find out how to keep this generated main program and look at it for an
idea of what else is needed to get an Ada program working.

-- 
Jeff Carter
"If you think you got a nasty taunting this time,
you ain't heard nothing yet!"
Monty Python and the Holy Grail



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

* Re: assembly generated using gcc -S on a .adb
  2002-07-08  2:55 assembly generated using gcc -S on a .adb KK
  2002-07-08  3:15 ` Jeffrey Carter
@ 2002-07-08  6:31 ` sk
  1 sibling, 0 replies; 3+ messages in thread
From: sk @ 2002-07-08  6:31 UTC (permalink / raw)


Hi,

> /usr/lib/crt1.o: In function `_start':
> /usr/lib/crt1.o(.text+0x18): undefined reference to `main'

If you can find and look at the 'specs' file for the linker,
you will see that "/usr/lib/crt1.o" is automatically part of
any (standard) executable you create.

This file provides a function "_start" which the linker, unless
specifically overridden, assumes is the entry point for the
final executable. 

The "_start" typically does some setup and then calls "main". 
There is a direct correlation between this "main" and the
typical "C" executable "int main (argc ...)". 

As J.Carter notes, look at the GNAT users manual to see how
the "main" is generated by the GNAT compilation process.

> I realize that gcc *is* a c compiler ...
Not really. gcc coordinates the language specific front ends, the
code generation and linking.

> In other words, is there a way for a machine with just gcc 
> installed, to produce an executable from an asm file that was 
> generated from an .adb ??

Yes, but as with any programming language, you need to have all
external references resolvable at link time. Your provided 
example would suggest that this implies you need to supply "main"
and keep hacking until there are no unresolved references. 

-- 
-------------------------------------
-- Merge vertically for real address
-------------------------------------
s n p @ t . o
 k i e k c c m
-------------------------------------



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

end of thread, other threads:[~2002-07-08  6:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-08  2:55 assembly generated using gcc -S on a .adb KK
2002-07-08  3:15 ` Jeffrey Carter
2002-07-08  6:31 ` sk

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