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 middle-end/15486] [3.3/3.4/3.5] -fdata-sections moves common vars to .bss


------- Additional Comments From jifl-bugzilla at jifvik dot org  2004-06-22 19:37 -------
I'm not arguing against the current behaviour as such. I think the current
behaviour would be a good idea as it allows GC of BSS sections; but it should
not be rolled into an existing option with an existing known action, breaking
long-standing behaviour used in lots of code. Or if it is, there should be a way
to stop it in this case.

Anyway, after some archaeology (:-)), I have found the patch that did it:
http://gcc.gnu.org/ml/gcc-patches/2002-03/msg00921.html
Specifically moving resolve_unique_section() before the check of
DECL_SECTION_NAME which is:

  /* If the decl has been given an explicit section name, then it
     isn't common, and shouldn't be handled as such.  */
  if (DECL_SECTION_NAME (decl) || dont_output_data)
    ;
  /* We don't implement common thread-local data at present.  */
  else
    [etc.]
It isn't clear what the rationale for this change was: the "more fallout"
referred to here is I believe subsequent to
http://gcc.gnu.org/ml/gcc-patches/2002-03/msg00768.html perhaps which is in turn
after Kaveh's changes to add -fno-zero-initialized-in-bss in
http://gcc.gnu.org/ml/gcc-patches/2002-03/msg00062.html

Jason presumably had come across some reason why Kaveh's change broke something.
But I don't think it was deliberately intended to remove common variable support
when using -fdata-sections. Given the other purpose of resolve_unique_section()
I would guess it's to do with the correct implementation of transparent unions,
which are used in several high-profile places in glibc, including most socket
functions and an argument to the wait() family of functions. Are there other
ways DECL_SECTION_NAME could be set before this point?

As to how to address this then, I'm not too hot on GCC internals, but the old
behaviour could be returned simply by making the above cited if actually:

  if (DECL_ONE_ONLY(decl) && DECL_SECTION_NAME (decl) || dont_output_data)

This would then allow the else clauses to be followed as expected. This is on
the assumption that the reasoning behind Jason's change is as per above. If it's
something else, hopefully the above info helps someone more knowledgable than I
work out what the rationale is.

Although I would say that someone should consider allowing -fdata-sections (or a
new -fbss-sections option) to operate on the BSS as well in future, due to the
space savings that could give, as long as there's a way to get back the current
behaviour.


-- 


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


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