This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Question about keywords and declarations in assembly code
- From: "Jafa" <jafa at silicondust dot com>
- To: <spr03 at uow dot edu dot au>,<binutils at sources dot redhat dot com>
- Date: Mon, 13 Oct 2003 08:41:51 -0700
- Subject: Re: Question about keywords and declarations in assembly code
- References: <d9065c55.d2329ca1.8189b00@mirapoint.uow.edu.au>
Hi,
You best bet is the online documentation...
http://www.gnu.org/manual
http://www.gnu.org/manual/gas-2.9.1/as.html
Further answers below... I am sure the experts here will correct anything I
have got wrong.
Nick
> Hi,
>
> I've been looking at the assembly code that is produced by
> gcc and have a few questions about some of the declarations
> and keywords found in the assembly file.
>
> When declaring variables in ".Lfe1", what does the following
> mean?
> .Lfe1:
> .comm aVariable,4,1
> .comm anotherVariable,4,1
>
> And what function does ".Lfe1" perform?
.Lfe is a label generated by gcc... I don't think it has any meaning to gas
(someone correct me if I am wrong).
.comm = common and they are generated by gcc for global variables that are
not pre-initialized and not static.
The linker will group like-named .comm variables and place them in the .bss
section.
Actually .comm is a PITA because it prevents some tricks you can do
manipulating .o files and causes probems with --gc-sections.
The way I figure it if you have two global variables of the same name then
you should get a linker error... merging the two may be the worst thing it
can do. Maybe there is some obscure C spec that requires this - hopfully
someone will clarify.
> I can see that the second number means the number of bytes
> this variable should take in memory - but what does the
> second number mean, and what does ".comm" stand for?
The alignment. If there is no second number then it means natural alignment
which is usually what you want.
> When a name of a function is declared "extern" in assembly
> what does this mean? i.e.
> extern aFunction
>
> When there is ".sect" , ".text" , and ".type" at the top of
> the main declaration what do these mean? i.e.
> .sect .text
> .type main,@function
>
> I'm guessing that the "main,@function" is saying that main
> is a function - is this correct?
Yes.
BTW - .text is the section == code.
> The ".globl" keyword I guess means that this function can be
> called from anywhere in the assembly code - is this correct?
> i.e.
> .globl aFunction
.global means that the label should be published outside of the context of
the current file.
Any c function that is not static will be marked global for gas - c assumes
global, gas assumes local scope.
> Is there an online manual where I can find answers to
> questions like these above??
http://www.gnu.org/manual
http://www.gnu.org/manual/gas-2.9.1/as.html
> Thankyou for your help with these questions, I really
> appreciate it.
>
> Simon Reynolds.
>
>