1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: package/.../embutils/ls-gcc-4.1-sparc-mis-opt.patch
5 # Copyright (C) 2007 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
15 # --- T2-COPYRIGHT-NOTE-END ---
17 GCC-4.1 on sparc64 appears to miscompile the expression. Out of 3 single byte
18 loads it forms a single DWORD ldx that does not potentially load too much data
19 (when the string is shorter) but also loads with an offset of -1, loading
20 one byte before the string. Either way it aborts with a SIGBUS (probably
21 also due analigned accesss) ...
23 The revisited code also should help GCC optimize some pointer dereferences
26 - Rene Rebe <rene@exactcode.de>
28 --- embutils-0.17/ls.c 2004-05-21 19:11:42.000000000 +0000
29 +++ embutils-0.17-fixed/ls.c 2006-12-20 18:03:42.000000000 +0000
31 while ((e=readdir(d))) {
34 - if (e->d_name[0]=='.') {
35 + const char* d_name=e->d_name;
36 + if (d_name[0]=='.') {
37 /* is it "." or ".."? */
38 - if (e->d_name[1]==0 || (e->d_name[1]=='.' && e->d_name[2]==0))
39 + if (d_name[1]==0 || (d_name[1]=='.' && d_name[2]==0))
40 if (_A || !_a) continue;
41 if (!_A && !_a) continue;
43 - expanded=alloca(strlen(name)+strlen(e->d_name)+3);
44 + expanded=alloca(strlen(name)+strlen(d_name)+3);
45 len=str_copy(expanded,name);
46 expanded[len]='/'; ++len;
47 - expanded[len+str_copy(expanded+len,e->d_name)]=0;
48 - dols(e->d_name,expanded,1);
49 + expanded[len+str_copy(expanded+len,d_name)]=0;
50 + dols(d_name,expanded,1);
54 --- embutils-0.17/rm.c.vanilla 2007-04-02 09:18:28.000000000 +0000
55 +++ embutils-0.17/rm.c 2007-04-02 09:19:50.000000000 +0000
57 while ((de=readdir(d))) {
60 - if (de->d_name[0]=='.')
61 - if ((de->d_name[1]=='.' && de->d_name[2]==0) ||
63 + const char* de_name=de->d_name;
65 + if (de_name[0]=='.')
66 + if ((de_name[1]=='.' && de_name[2]==0) ||
69 - buf=alloca(strlen(filename)+strlen(de->d_name)+2);
70 + buf=alloca(strlen(filename)+strlen(de_name)+2);
71 len=str_copy(buf,filename);
73 - len+=str_copy(buf+len,de->d_name);
74 + len+=str_copy(buf+len,de_name);