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]

Re: PR7455: What is expected behavior for #pragma weak.


On Sun, Jan 11, 2004 at 11:26:18PM +0100, Steven Bosscher wrote:
> Hi,
> 
> Bug 7455 is a "wrong-code" bug about weak symbols.  In the past,
> the following code:
> _____________________________
> #pragma weak bar = foo
> _____________________________
> 
> would give:
> 
>         .file   "t.c"
>         .version        "01.01"
> gcc2_compiled.:
>         .weak   bar
>         .set    bar,foo
>         .ident  "GCC: (GNU) 2.95.4 20011002 (Debian prerelease)"
> 
> Newer GCCs do not write the weak symbol:

Correct.  The the assembly above is meaningless.  It "works" in that it
assembles, but it doesn't do anything useful.  One could even argue that
it's a bug that it assembles.

> But this one,
> _____________________________
> extern int bar (void) __attribute__ ((weak));
> _____________________________
> 
> gives:
>         .file   "t.c"
>         .section        .note.GNU-stack,"",@progbits
>         .ident  "GCC: (GNU) 3.4.0 20040111 (experimental)"

This is correct as well.  Bar should be marked weak if it is used, but
since it is not used there's no need for it to be mentioned at all.


r~


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