This is the mail archive of the gcc-bugs@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]

[Bug c++/14769] Block extern incorrectly resolved to file-scope internal linkage object


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-29 12:15 -------
It seems to work correctly for me (for -fPIC and without I will only show with):
(without the extern int i;):
main:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %ebx
        subl    $20, %esp
        call    .LPR3
        addl    $_GLOBAL_OFFSET_TABLE_, %ebx
        andl    $-16, %esp
        movl    $0, %eax
        subl    %eax, %esp
        movl    8(%ebp), %eax
        movl    %eax, 4(%esp)
        leal    .LC0@GOTOFF(%ebx), %eax
        movl    %eax, (%esp)
        call    printf@PLT
        movl    $0, %eax
        movl    -4(%ebp), %ebx
        leave
        ret
See how there is no reference to i, meaning that i is already "inlined".
Here are the asm for with the "extern int i;":
main:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %ebx
        subl    $20, %esp
        call    .LPR3
        addl    $_GLOBAL_OFFSET_TABLE_, %ebx
        andl    $-16, %esp
        movl    $0, %eax
        subl    %eax, %esp
        movl    i@GOT(%ebx), %eax
        movl    (%eax), %eax
        movl    %eax, 4(%esp)
        leal    .LC0@GOTOFF(%ebx), %eax
        movl    %eax, (%esp)
        call    printf@PLT
        movl    $0, %eax
        movl    -4(%ebp), %ebx
        leave
        ret
See how it goes through GOT,meaning it will pick up the extern one and not really always the local one.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14769


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