This is the mail archive of the gcc-patches@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: PATCH: Don't allow weak variables in COMMON




--On Friday, May 24, 2002 12:23:35 AM -0700 "David S. Miller" 
<davem@redhat.com> wrote:

>    From: Mark Mitchell <mark@codesourcery.com>
>    Date: Thu, 23 May 2002 11:05:39 -0700
>
>    If you tried something like:
>
>      __attribute__((weak) int i;
>
>    you got an assembler error telling you that you can't have weak
>    symbols in common.
>
> What about similar situations using __attribute__(section("foo"))?
> Should we un-common the thing in those cases too?

Probably.

> I personally think it is a bug to mark something implicitly BSS then
> tell the compiler "oh sorry, I didn't want it to be BSS actually".

Abstractly, the front ends should know nothing of these object-format
details.  They should say "This has an initializer, this doesn't" and
"This one should be shared across all object files" and "This one
should go in this section".

The real bug here is that start_decl in c-decl.c sets DECL_COMMON.
Setting DECL_COMMON should be purely a middle-end thing; probably
make_decl_rtl should be responsible for setting it one way or the
other.  (Right now, it seems that make_decl_rtl is responsible for
undoing the front ends mistakes.)

> Just un-BSS it by initializing it to zero if that is what you want.

Do you mean in the compiler or at user level?

In other words, are you suggesting that the code quoted above is
actually erroneous, and that the user should write "= 0"?  Or do
you mean that the front end should have set DECL_INIT to an
expression for a zero of the proper type?

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com


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