public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: fix new sigfe.o generation in optimized case
@ 2022-05-13 19:23 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2022-05-13 19:23 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8f66bc28ae461763d1da91384a652512590eea16
commit 8f66bc28ae461763d1da91384a652512590eea16
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Fri May 13 21:22:44 2022 +0200
Cygwin: fix new sigfe.o generation in optimized case
Commit 0597c84b9bdb ("Cygwin: revamp TLS offsets computation")
introduced a really weird problem when building Cygwin with
optimization.
First of all, the tlsoffsets file is broken with -O2. This
can easily be fixed by running the compiler with -O0 when called
from the gentls_offsets script.
But it gets worse:
When creating sigfe.o with optimization, the generated machine code
uses incorrect offsets: For some reason the assembler codes using
_cygtls.stackptr as offset value are assembled into machine code
using _cygtls.pstackptr as offsets.
And as if that isn't already absurd enough, renaming _cygtls.pstackptr
to, say, _cygtls.blurb, fixes the assembled machine code expressions;
they use the value of _cygtls.stackptr again.
So I changed gentls_offsets and gendef to use _cygtls.foo_p rather
than _cygtls.pfoo and that fixes the assembled code in the optimized
case.
No, I can't explain that. There's no system in that behaviour.
It looks absolutely crazy.
Fixes: 0597c84b9bdb ("Cygwin: revamp TLS offsets computation")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/gendef | 16 ++++++++--------
winsup/cygwin/gentls_offsets | 6 +++---
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/winsup/cygwin/gendef b/winsup/cygwin/gendef
index 779cdcfd0..577dfe8ee 100755
--- a/winsup/cygwin/gendef
+++ b/winsup/cygwin/gendef
@@ -318,7 +318,7 @@ _sigdelayed_end:
_ZN7_cygtls3popEv:
.seh_endprologue
movq \$-8,%r11
- xaddq %r11,_cygtls.pstackptr(%rcx)
+ xaddq %r11,_cygtls.stackptr_p(%rcx)
movq -8(%r11),%rax
ret
.seh_endproc
@@ -332,7 +332,7 @@ _ZN7_cygtls4lockEv:
.seh_endprologue
movq %rcx,%r12
1: movl \$1,%r11d
- xchgl %r11d,_cygtls.pstacklock(%r12)
+ xchgl %r11d,_cygtls.stacklock_p(%r12)
testl %r11d,%r11d
jz 2f
pause
@@ -346,7 +346,7 @@ _ZN7_cygtls4lockEv:
.seh_proc _ZN7_cygtls6unlockEv
_ZN7_cygtls6unlockEv:
.seh_endprologue
- decl _cygtls.pstacklock(%rcx)
+ decl _cygtls.stacklock_p(%rcx)
ret
.seh_endproc
@@ -355,7 +355,7 @@ _ZN7_cygtls6unlockEv:
.seh_proc _ZN7_cygtls6lockedEv
_ZN7_cygtls6lockedEv:
.seh_endprologue
- movl _cygtls.pstacklock(%rcx),%eax
+ movl _cygtls.stacklock_p(%rcx),%eax
ret
.seh_endproc
@@ -528,7 +528,7 @@ __ZN7_cygtls3popEv\@4:
1: pushl %ebx
movl %eax,%ebx # this
movl \$-4,%eax
- xadd %eax,_cygtls.pstackptr(%ebx)
+ xadd %eax,_cygtls.stackptr_p(%ebx)
movl -4(%eax),%eax
popl %ebx
ret
@@ -539,7 +539,7 @@ __ZN7_cygtls4lockEv\@4:
pushl %ebx
movl %eax,%ebx
1: movl \$1,%eax
- xchgl %eax,_cygtls.pstacklock(%ebx)
+ xchgl %eax,_cygtls.stacklock_p(%ebx)
testl %eax,%eax
jz 2f
call _yield
@@ -550,12 +550,12 @@ __ZN7_cygtls4lockEv\@4:
# _cygtls::unlock
.global __ZN7_cygtls6unlockEv\@4
__ZN7_cygtls6unlockEv\@4:
- decl _cygtls.pstacklock(%eax)
+ decl _cygtls.stacklock_p(%eax)
ret
.global __ZN7_cygtls6lockedEv
__ZN7_cygtls6lockedEv:
- movl _cygtls.pstacklock(%eax),%eax
+ movl _cygtls.stacklock_p(%eax),%eax
ret
.extern __ZN7_cygtls19call_signal_handlerEv\@4
diff --git a/winsup/cygwin/gentls_offsets b/winsup/cygwin/gentls_offsets
index 6892bd528..d76562c05 100755
--- a/winsup/cygwin/gentls_offsets
+++ b/winsup/cygwin/gentls_offsets
@@ -43,7 +43,7 @@ gawk '
}
' | \
# Now run the compiler to generate an assembler file.
-${CXXCOMPILE} -x c++ -g0 -S - -o - | \
+${CXXCOMPILE} -x c++ -g0 -O0 -S - -o - | \
# The assembler file consists of lines like these:
#
# __CYGTLS__foo
@@ -63,7 +63,7 @@ gawk '\
/\s*\.space\s*4/ {
if (length (varname) > 0) {
printf (".equ _cygtls.%s, %d\n", varname, -start_offset);
- printf (".equ _cygtls.p%s, 0\n", varname);
+ printf (".equ _cygtls.%s_p, 0\n", varname);
varname = "";
}
}
@@ -75,7 +75,7 @@ gawk '\
} else {
value = $2;
printf (".equ _cygtls.%s, %d\n", varname, value - start_offset);
- printf (".equ _cygtls.p%s, %d\n", varname, value);
+ printf (".equ _cygtls.%s_p, %d\n", varname, value);
}
varname = "";
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-13 19:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13 19:23 [newlib-cygwin] Cygwin: fix new sigfe.o generation in optimized case Corinna Vinschen
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).