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]

PR7455: What is expected behavior for #pragma weak.


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:

        .file   "t.c"
        .section        .note.GNU-stack,"",@progbits
        .ident  "GCC: (GNU) 3.4.0 20040111 (experimental)"

Notice how the test case does not actually declare bar.  The following
cases do work with all recent GCCs:
_____________________________
#pragma weak bar = foo
extern int bar (void);
_____________________________

gives:
        .file   "t.c"
        .weak   bar
        .set    bar,foo
        .section        .note.GNU-stack,"",@progbits
        .ident  "GCC: (GNU) 3.4.0 20040111 (experimental)"

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)"

What is the expected result in each of these cases, and especially the
last one of them?  The documentation on weak symbols doesn't help a lot.

Gr.
Steven



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