This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] fix PR 33168
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Nathan Froyd <froydnj at codesourcery dot com>, David Edelsohn <dje at watson dot ibm dot com>, Alan Modra <amodra at bigpond dot net dot au>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 27 Aug 2007 09:38:52 -0400
- Subject: Re: [PATCH] fix PR 33168
- References: <20070824205455.GA15735@codesourcery.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Aug 24, 2007 at 01:54:55PM -0700, Nathan Froyd wrote:
- if (strcmp (section, ".sdata") == 0
- || strcmp (section, ".sdata2") == 0
- || strcmp (section, ".sbss") == 0
- || strcmp (section, ".sbss2") == 0
- || strcmp (section, ".PPC.EMB.sdata0") == 0
- || strcmp (section, ".PPC.EMB.sbss0") == 0)
+ if (strncmp (section, ".sdata", strlen (".sdata")) == 0
+ || strncmp (section, ".sdata2", strlen (".sdata2")) == 0
+ || strncmp (section, ".sbss", strlen (".sbss")) == 0
+ || strncmp (section, ".sbss2", strlen (".sbss2")) == 0
+ || strncmp (section, ".PPC.EMB.sdata0", strlen (".PPC.EMB.sdata0")) == 0
+ || strncmp (section, ".PPC.EMB.sbss0", strlen (".PPC.EMB.sbss0")) == 0)
This looks wrong to me. .sdataabc section is not considered
to be a small data section by the linker.
If that would be correct, the .sdata2 and .sbss2 comparisons above would
be redundant.
Anyway, you want to consider:
.sdata .sdata.* .gnu.linkonce.s.*
.sbss .sbss.* .gnu.linkonce.sb.*
If *2 sections are appropriate for this use (it is a different area), then
.sdata2 .sdata2.* .gnu.linkonce.s2.*
.sbss2 .sbss2.* .gnu.linkonce.sb2.*
and
.PPC.EMB.sdata0 .PPC.EMB.sbss0
only as is.
So IMHO the above needs to be something like:
if ((strncmp (section, ".sdata", sizeof (".sdata") - 1) == 0
&& (section[sizeof (".sdata") - 1] == '\0'
|| section[sizeof (".sdata") - 1] == '.'
|| (section[sizeof (".sdata") - 1] == '2'
&& (section[sizeof (".sdata")] == '\0'
|| section[sizeof (".sdata")] == '.'))))
|| (strncmp (section, ".sbss", sizeof (".sbss") - 1) == 0
&& (section[sizeof (".sbss") - 1] == '\0'
|| section[sizeof (".sbss") - 1] == '.'
|| (section[sizeof (".sbss") - 1] == '2'
&& (section[sizeof (".sbss")] == '\0'
|| section[sizeof (".sbss")] == '.'))))
|| (strncmp (section, ".gnu.linkonce.s", sizeof (".gnu.linkonce.s") - 1) == 0
&& (section[sizeof (".gnu.linkonce.s") - 1] == '.'
|| ((section[sizeof (".gnu.linkonce.s") - 1] == '2'
|| section[sizeof (".gnu.linkonce.s") - 1] == 'b')
&& section[sizeof (".gnu.linkonce.s")] == '.')
|| (section[sizeof (".gnu.linkonce.s") - 1] == 'b'
&& section[sizeof (".gnu.linkonce.s")] == '2'
&& section[sizeof (".gnu.linkonce.s") + 1] == '.')))
|| strcmp (section, ".PPC.EMB.sdata0") == 0
|| strcmp (section, ".PPC.EMB.sbss0") == 0)
Jakub