This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

".globl" symbol


Hi,
Please look at the following code:

test1.c                        test2.c
--------                       --------
int s;                         int s = 4;
main() {};                     main() {};

Please look at the assembly code generated in both
cases: 

test1.c
--------------------------------------------------
        .file   "test1.c"
        .version        "01.01"
gcc2_compiled.:
.text
        .p2align 2,0x90
.globl main
        .type    main,@function
main:
        pushl %ebp
        movl %esp,%ebp
.L2:
        leave
        ret
.Lfe1:
        .size    main,.Lfe1-main
        .comm   s,4,4
        .ident  "[ASM_FILE_END]GCC: (c) 2.95.219991024
(release)"
-----------------------------------------------------


test2.s
----------------------------------------------------- 
      .file   "test2.c"
        .version        "01.01"
gcc2_compiled.:
.globl s    <======= PLEASE NOTE
.data
        .p2align 2         
        .type s,@object
        .size    s,4
s:
        .long 4
.text
        .p2align 2,0x90
.globl main
        .type    main,@function
main:
        pushl %ebp
        movl %esp,%ebp
.L2:
        leave
        ret
.Lfe1:
        .size    main,.Lfe1-main
        .ident  "[ASM_FILE_END]GCC: (c) 2.95.2
19991024 (release)"
----------------------------------------------------
           
My question is that why in second case "s" is being
declared as a ".globl" and in first case not?

I am using gcc version 2.95.2. I am running the
programs on a i386 machine running FreeBsd 4.0

thanks,
Steve

__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - send holiday greetings for Easter, Passover
http://greetings.yahoo.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]