# --- T2-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # T2 SDE: package/.../embutils/ls-gcc-4.1-sparc-mis-opt.patch # Copyright (C) 2007 The T2 SDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # --- T2-COPYRIGHT-NOTE-END --- GCC-4.1 on sparc64 appears to miscompile the expression. Out of 3 single byte loads it forms a single DWORD ldx that does not potentially load too much data (when the string is shorter) but also loads with an offset of -1, loading one byte before the string. Either way it aborts with a SIGBUS (probably also due analigned accesss) ... The revisited code also should help GCC optimize some pointer dereferences away ... - Rene Rebe --- embutils-0.17/ls.c 2004-05-21 19:11:42.000000000 +0000 +++ embutils-0.17-fixed/ls.c 2006-12-20 18:03:42.000000000 +0000 @@ -731,17 +731,18 @@ while ((e=readdir(d))) { int len; char *expanded; - if (e->d_name[0]=='.') { + const char* d_name=e->d_name; + if (d_name[0]=='.') { /* is it "." or ".."? */ - if (e->d_name[1]==0 || (e->d_name[1]=='.' && e->d_name[2]==0)) + if (d_name[1]==0 || (d_name[1]=='.' && d_name[2]==0)) if (_A || !_a) continue; if (!_A && !_a) continue; } - expanded=alloca(strlen(name)+strlen(e->d_name)+3); + expanded=alloca(strlen(name)+strlen(d_name)+3); len=str_copy(expanded,name); expanded[len]='/'; ++len; - expanded[len+str_copy(expanded+len,e->d_name)]=0; - dols(e->d_name,expanded,1); + expanded[len+str_copy(expanded+len,d_name)]=0; + dols(d_name,expanded,1); } closedir(d); if (fchdir(savedir)) --- embutils-0.17/rm.c.vanilla 2007-04-02 09:18:28.000000000 +0000 +++ embutils-0.17/rm.c 2007-04-02 09:19:50.000000000 +0000 @@ -100,14 +100,16 @@ while ((de=readdir(d))) { int len; char *buf; - if (de->d_name[0]=='.') - if ((de->d_name[1]=='.' && de->d_name[2]==0) || - de->d_name[1]==0) + const char* de_name=de->d_name; + + if (de_name[0]=='.') + if ((de_name[1]=='.' && de_name[2]==0) || + de_name[1]==0) continue; - buf=alloca(strlen(filename)+strlen(de->d_name)+2); + buf=alloca(strlen(filename)+strlen(de_name)+2); len=str_copy(buf,filename); buf[len]='/'; ++len; - len+=str_copy(buf+len,de->d_name); + len+=str_copy(buf+len,de_name); rm(buf); } closedir(d);