public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug pch/31634]  New: *_SECTION_ASM_OP storage has undocumented constraints
@ 2007-04-19 17:57 amylaar at gcc dot gnu dot org
  2007-04-19 18:27 ` [Bug pch/31634] " amylaar at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2007-04-19 17:57 UTC (permalink / raw)
  To: gcc-bugs

The macros TEXT_SECTION_ASM_OP, DATA_SECTION_ASM_OP, SDATA_SECTION_ASM_OP,
READONLY_DATA_SECTION_ASM_OP, CTORS_SECTION_ASM_OP, DTORS_SECTION_ASM_OP,
BSS_SECTION_ASM_OP and SBSS_SECTION_ASM_OP are used by
varasm.c:init_varasm_once
to pass their value to get_unnamed_section; the result of that function call
is then stored into a ggc root.
That means that pch fails if the string value one of these macros is in storage
that is not pch-safe, and the string is subsequently used in a compilation
useing
a precompiled header.
In particular, ggc-allocated strings are safe; string literals might be safe,
if they come from a cc1 binary (rather than a dso), and no address space
randomization is in effect.  (x)malloced emmory is not safe.

What I see with some gcc/dg/pch test cases for a port which uses xmalloed
memory is that the sections are swaitched around, most often .text against
.data (for valid-2.c Letext0 ended up in .data), but also .text or .rodata
against nothing (i.e. carry on in previous section), or just some garbage
string. 

We should either remove this restriction, or document it.

Considering that many ports use string literals, and many hosts in the wild
now use address space randomization, I think we should remove this
restriction by copying the string to ggc-allocated memory.

As far as I can see, all uses of get_unnamed_section pass a NULL or string
as third parameter, except for the rs6000, which passes pointers to
global variables - which in the case of address space randomization on the
host is just as unsuitable as a string literal.
The rs6000 cannot be converted trivially to using strings, since the variables
addresses are used in code called from backend_init, while the initialization
of the variables is called from do_compile, which is three lines down in
toplev.c:do_compile.

So I think the easiest solution is change get_unnamed_section to take a char*
for the third argument, which is copied to ggc-ed memory if not NULL, and
have another function providing the old functionality of get_unnamed_section
for the rs6000 target non-string usages.

The rs6000 target port could presumably be fixed to
work on a host with address space randomization by using indices into an
array instead of pointers, or by forcing initialization of the section names
from rs6000_xcoff_asm_init_sections, but this is really a separate issue.


-- 
           Summary: *_SECTION_ASM_OP storage has undocumented constraints
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code, ice-on-valid-code, wrong-debug, link-
                    failure, assemble-failure
          Severity: normal
          Priority: P3
         Component: pch
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: amylaar at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug pch/31634] *_SECTION_ASM_OP storage has undocumented constraints
  2007-04-19 17:57 [Bug pch/31634] New: *_SECTION_ASM_OP storage has undocumented constraints amylaar at gcc dot gnu dot org
@ 2007-04-19 18:27 ` amylaar at gcc dot gnu dot org
  2007-05-02 12:43 ` amylaar at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2007-04-19 18:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from amylaar at gcc dot gnu dot org  2007-04-19 19:27 -------
On second thought, the implementation is simpler when NULL is not treated
specially.  But then there is a slight majority of the uses in the
config directory that wants the old behaviour of get_unnamed_section,
so it makes sense to use a new name for the new function - or macro -
which does an ggc_strdup of the third argument.


-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug pch/31634] *_SECTION_ASM_OP storage has undocumented constraints
  2007-04-19 17:57 [Bug pch/31634] New: *_SECTION_ASM_OP storage has undocumented constraints amylaar at gcc dot gnu dot org
  2007-04-19 18:27 ` [Bug pch/31634] " amylaar at gcc dot gnu dot org
@ 2007-05-02 12:43 ` amylaar at gcc dot gnu dot org
  2009-03-04 21:56 ` amylaar at gcc dot gnu dot org
  2009-03-05  0:27 ` amylaar at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2007-05-02 12:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from amylaar at gcc dot gnu dot org  2007-05-02 13:42 -------
(In reply to comment #1)

Actually, struct unnamed_section is not suitable for garbage collected memory.
The data member is skipped, and the callback member points to a function,
which can change position when address space randomization is in effect.

I think the best solution is not to garbage collect unnamed sections.
If precompiled headers are compatible, we should be using the same set of
unnamed
sections in the compilation that uses the header as in the compilation that
created the precompiled header.


-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug pch/31634] *_SECTION_ASM_OP storage has undocumented constraints
  2007-04-19 17:57 [Bug pch/31634] New: *_SECTION_ASM_OP storage has undocumented constraints amylaar at gcc dot gnu dot org
  2007-04-19 18:27 ` [Bug pch/31634] " amylaar at gcc dot gnu dot org
  2007-05-02 12:43 ` amylaar at gcc dot gnu dot org
@ 2009-03-04 21:56 ` amylaar at gcc dot gnu dot org
  2009-03-05  0:27 ` amylaar at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2009-03-04 21:56 UTC (permalink / raw)
  To: gcc-bugs



-- 

amylaar at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|39302                       |
OtherBugsDependingO|                            |39363
              nThis|                            |
         AssignedTo|unassigned at gcc dot gnu   |amylaar at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
           Keywords|                            |patch
   Last reconfirmed|0000-00-00 00:00:00         |2009-03-04 21:56:38
               date|                            |


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug pch/31634] *_SECTION_ASM_OP storage has undocumented constraints
  2007-04-19 17:57 [Bug pch/31634] New: *_SECTION_ASM_OP storage has undocumented constraints amylaar at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-03-04 21:56 ` amylaar at gcc dot gnu dot org
@ 2009-03-05  0:27 ` amylaar at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2009-03-05  0:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from amylaar at gcc dot gnu dot org  2009-03-05 00:27 -------
The patch is here:
http://gcc.gnu.org/ml/gcc-patches/2009-03/msg00243.html


-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug pch/31634] *_SECTION_ASM_OP storage has undocumented constraints
       [not found] <bug-31634-4@http.gcc.gnu.org/bugzilla/>
@ 2014-11-09 14:34 ` amylaar at gcc dot gnu.org
  0 siblings, 0 replies; 6+ messages in thread
From: amylaar at gcc dot gnu.org @ 2014-11-09 14:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31634

--- Comment #4 from Jorn Wolfgang Rennecke <amylaar at gcc dot gnu.org> ---
31634 used to be relevant for ARC, but that port has since ceased to
support changing the name if TEXT_SECTION_ASM_OP etc. by command line
option, and uses now a string literal, precisely in order to work around
this bug.
Hence, this no longer blocks other/39363 .


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-11-09 14:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-19 17:57 [Bug pch/31634] New: *_SECTION_ASM_OP storage has undocumented constraints amylaar at gcc dot gnu dot org
2007-04-19 18:27 ` [Bug pch/31634] " amylaar at gcc dot gnu dot org
2007-05-02 12:43 ` amylaar at gcc dot gnu dot org
2009-03-04 21:56 ` amylaar at gcc dot gnu dot org
2009-03-05  0:27 ` amylaar at gcc dot gnu dot org
     [not found] <bug-31634-4@http.gcc.gnu.org/bugzilla/>
2014-11-09 14:34 ` amylaar at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).