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] fix PR 33168


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


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