* cygtls.cc (_cygtls::remove): Revert previous patch.

*  cygtls.h (struct _local_storage): Move pathbufs back here.
	(class san/x86_64): Revert class.  Save and restore pathbufs counters
	only.
	(class san/i686): Revert saving and restoring pathbufs counters.
	(__try/x86_64): Add a san variable and call it's setup method.
	(__except/x86_64): Call san::leave to restore pathbufs counters.
	* gendef (_sigbe): Revert previous change.
	* thread.cc (verifyable_object_state): Remove gcc 4.7 workaround in
	forward declaration as well.
	* tls_pbuf.cc (tls_pbuf): Revert previous change.
	* tls_pbuf.h (class tmp_pathbuf): Accommodate reverting pathbufs to
	locals structure.
	* tlsoffsets.h: Regenerate.
	* tlsoffsets64.h: Regenerate.
This commit is contained in:
Corinna Vinschen 2014-08-25 14:53:49 +00:00
parent 3f3bd10104
commit 5578cc4b73
9 changed files with 206 additions and 178 deletions

View File

@ -1,3 +1,21 @@
2014-08-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.cc (_cygtls::remove): Revert previous patch.
* cygtls.h (struct _local_storage): Move pathbufs back here.
(class san/x86_64): Revert class. Save and restore pathbufs counters
only.
(class san/i686): Revert saving and restoring pathbufs counters.
(__try/x86_64): Add a san variable and call it's setup method.
(__except/x86_64): Call san::leave to restore pathbufs counters.
* gendef (_sigbe): Revert previous change.
* thread.cc (verifyable_object_state): Remove gcc 4.7 workaround in
forward declaration as well.
* tls_pbuf.cc (tls_pbuf): Revert previous change.
* tls_pbuf.h (class tmp_pathbuf): Accommodate reverting pathbufs to
locals structure.
* tlsoffsets.h: Regenerate.
* tlsoffsets64.h: Regenerate.
2014-08-21 Corinna Vinschen <corinna@vinschen.de> 2014-08-21 Corinna Vinschen <corinna@vinschen.de>
* Throughout, use __try/__except/__endtry blocks, rather than myfault * Throughout, use __try/__except/__endtry blocks, rather than myfault

View File

@ -193,7 +193,7 @@ _cygtls::remove (DWORD wait)
free_local (servent_buf); free_local (servent_buf);
free_local (hostent_buf); free_local (hostent_buf);
/* Free temporary TLS path buffers. */ /* Free temporary TLS path buffers. */
pathbufs.destroy (); locals.pathbufs.destroy ();
/* Close timer handle. */ /* Close timer handle. */
if (locals.cw_timer) if (locals.cw_timer)
NtClose (locals.cw_timer); NtClose (locals.cw_timer);

View File

@ -132,6 +132,7 @@ struct _local_storage
/* thread.cc */ /* thread.cc */
HANDLE cw_timer; HANDLE cw_timer;
tls_pathbuf pathbufs;
char ttybuf[32]; char ttybuf[32];
}; };
@ -189,7 +190,6 @@ public:
struct pthread *tid; struct pthread *tid;
class cygthread *_ctinfo; class cygthread *_ctinfo;
class san *andreas; class san *andreas;
tls_pathbuf pathbufs;
waitq wq; waitq wq;
int sig; int sig;
unsigned incyg; unsigned incyg;
@ -288,20 +288,45 @@ extern PVOID _tlstop __asm__ ("%fs:8");
extern _cygtls *_main_tls; extern _cygtls *_main_tls;
extern _cygtls *_sig_tls; extern _cygtls *_sig_tls;
#ifndef __x86_64__ #ifdef __x86_64__
class san
{
unsigned _c_cnt;
unsigned _w_cnt;
public:
void setup () __attribute__ ((always_inline))
{
_c_cnt = _my_tls.locals.pathbufs.c_cnt;
_w_cnt = _my_tls.locals.pathbufs.w_cnt;
}
void leave () __attribute__ ((always_inline))
{
/* Restore tls_pathbuf counters in case of error. */
_my_tls.locals.pathbufs.c_cnt = _c_cnt;
_my_tls.locals.pathbufs.w_cnt = _w_cnt;
}
};
#else
class san class san
{ {
san *_clemente; san *_clemente;
jmp_buf _context; jmp_buf _context;
unsigned _c_cnt;
unsigned _w_cnt;
public: public:
int setup () __attribute__ ((always_inline)) int setup () __attribute__ ((always_inline))
{ {
_clemente = _my_tls.andreas; _clemente = _my_tls.andreas;
_my_tls.andreas = this; _my_tls.andreas = this;
_c_cnt = _my_tls.locals.pathbufs.c_cnt;
_w_cnt = _my_tls.locals.pathbufs.w_cnt;
return __sjfault (_context); return __sjfault (_context);
} }
void leave () __attribute__ ((always_inline)) void leave () __attribute__ ((always_inline))
{ {
/* Restore tls_pathbuf counters in case of error. */
_my_tls.locals.pathbufs.c_cnt = _c_cnt;
_my_tls.locals.pathbufs.w_cnt = _w_cnt;
__ljfault (_context, 1); __ljfault (_context, 1);
} }
void reset () __attribute__ ((always_inline)) void reset () __attribute__ ((always_inline))
@ -331,6 +356,7 @@ public:
#define __try \ #define __try \
{ \ { \
__label__ __l_try, __l_except, __l_endtry; \ __label__ __l_try, __l_except, __l_endtry; \
san __sebastian; \
__mem_barrier; \ __mem_barrier; \
__asm__ goto ("\n" \ __asm__ goto ("\n" \
" .seh_handler _ZN9exception7myfaultEP17_EXCEPTION_RECORDPvP8_CONTEXTP19_DISPATCHER_CONTEXT, @except \n" \ " .seh_handler _ZN9exception7myfaultEP17_EXCEPTION_RECORDPvP8_CONTEXTP19_DISPATCHER_CONTEXT, @except \n" \
@ -339,6 +365,7 @@ public:
" .rva %l[__l_try],%l[__l_endtry],%l[__l_except],%l[__l_except] \n" \ " .rva %l[__l_try],%l[__l_endtry],%l[__l_except],%l[__l_except] \n" \
" .seh_code \n" \ " .seh_code \n" \
: : : : __l_try, __l_endtry, __l_except); \ : : : : __l_try, __l_endtry, __l_except); \
__sebastian.setup (); \
{ \ { \
__l_try: \ __l_try: \
__mem_barrier; __mem_barrier;
@ -352,6 +379,7 @@ public:
{ \ { \
__l_except: \ __l_except: \
__mem_barrier; \ __mem_barrier; \
__sebastian.leave (); \
if (__errno) \ if (__errno) \
set_errno (__errno); set_errno (__errno);

View File

@ -181,8 +181,6 @@ _sigbe: # return here after cygwin syscall
movq -8(%r11),%r11 # get return address from signal stack movq -8(%r11),%r11 # get return address from signal stack
decl $tls::incyg(%r10) decl $tls::incyg(%r10)
decl $tls::stacklock(%r10) # release lock decl $tls::stacklock(%r10) # release lock
leaq $tls::pathbufs(%r10),%r10 # Address of tls_pathbufs
movq \$0,(%r10) # Set c_cnt and w_cnt to 0
jmp *%r11 # "return" to caller jmp *%r11 # "return" to caller
.seh_endproc .seh_endproc
@ -447,9 +445,6 @@ __sigbe: # return here after cygwin syscall
xchgl %eax,4(%esp) # swap return address with saved eax xchgl %eax,4(%esp) # swap return address with saved eax
decl $tls::incyg(%ebx) decl $tls::incyg(%ebx)
decl $tls::stacklock(%ebx) # release lock decl $tls::stacklock(%ebx) # release lock
leal $tls::pathbufs(%ebx),%ebx # Address of tls_pathbufs
movl \$0,(%ebx) # Set c_cnt to 0
movl \$0,4(%ebx) # Set w_cnt to 0
popl %ebx popl %ebx
ret ret

View File

@ -38,12 +38,7 @@ extern "C" void __fp_lock_all ();
extern "C" void __fp_unlock_all (); extern "C" void __fp_unlock_all ();
extern "C" int valid_sched_parameters(const struct sched_param *); extern "C" int valid_sched_parameters(const struct sched_param *);
extern "C" int sched_set_thread_priority(HANDLE thread, int priority); extern "C" int sched_set_thread_priority(HANDLE thread, int priority);
#if __GNUC__ == 4 && __GNUC_MINOR__ >= 7
/* FIXME: Temporarily workaround gcc 4.7+ bug. */
static verifyable_object_state
#else
static inline verifyable_object_state static inline verifyable_object_state
#endif
verifyable_object_isvalid (void const * objectptr, thread_magic_t magic, verifyable_object_isvalid (void const * objectptr, thread_magic_t magic,
void *static_ptr1 = NULL, void *static_ptr1 = NULL,
void *static_ptr2 = NULL, void *static_ptr2 = NULL,

View File

@ -10,7 +10,7 @@ details. */
#include <malloc.h> #include <malloc.h>
#include "tls_pbuf.h" #include "tls_pbuf.h"
#define tls_pbuf _my_tls.pathbufs #define tls_pbuf _my_tls.locals.pathbufs
void void
tls_pathbuf::destroy () tls_pathbuf::destroy ()

View File

@ -14,13 +14,13 @@ class tmp_pathbuf
uint32_t w_buf_old; uint32_t w_buf_old;
public: public:
tmp_pathbuf () __attribute__ ((always_inline)) tmp_pathbuf () __attribute__ ((always_inline))
: c_buf_old (_my_tls.pathbufs.c_cnt), : c_buf_old (_my_tls.locals.pathbufs.c_cnt),
w_buf_old (_my_tls.pathbufs.w_cnt) w_buf_old (_my_tls.locals.pathbufs.w_cnt)
{} {}
~tmp_pathbuf () __attribute__ ((always_inline)) ~tmp_pathbuf () __attribute__ ((always_inline))
{ {
_my_tls.pathbufs.c_cnt = c_buf_old; _my_tls.locals.pathbufs.c_cnt = c_buf_old;
_my_tls.pathbufs.w_cnt = w_buf_old; _my_tls.locals.pathbufs.w_cnt = w_buf_old;
} }
inline bool check_usage (uint32_t c_need, uint32_t w_need) inline bool check_usage (uint32_t c_need, uint32_t w_need)

View File

@ -3,46 +3,44 @@
//; $tls::start_offset = -12700; //; $tls::start_offset = -12700;
//; $tls::locals = -12700; //; $tls::locals = -12700;
//; $tls::plocals = 0; //; $tls::plocals = 0;
//; $tls::local_clib = -11388; //; $tls::local_clib = -10980;
//; $tls::plocal_clib = 1312; //; $tls::plocal_clib = 1720;
//; $tls::__dontuse = -11388; //; $tls::__dontuse = -10980;
//; $tls::p__dontuse = 1312; //; $tls::p__dontuse = 1720;
//; $tls::func = -10300; //; $tls::func = -9892;
//; $tls::pfunc = 2400; //; $tls::pfunc = 2808;
//; $tls::saved_errno = -10296; //; $tls::saved_errno = -9888;
//; $tls::psaved_errno = 2404; //; $tls::psaved_errno = 2812;
//; $tls::sa_flags = -10292; //; $tls::sa_flags = -9884;
//; $tls::psa_flags = 2408; //; $tls::psa_flags = 2816;
//; $tls::oldmask = -10288; //; $tls::oldmask = -9880;
//; $tls::poldmask = 2412; //; $tls::poldmask = 2820;
//; $tls::deltamask = -10284; //; $tls::deltamask = -9876;
//; $tls::pdeltamask = 2416; //; $tls::pdeltamask = 2824;
//; $tls::errno_addr = -10280; //; $tls::errno_addr = -9872;
//; $tls::perrno_addr = 2420; //; $tls::perrno_addr = 2828;
//; $tls::sigmask = -10276; //; $tls::sigmask = -9868;
//; $tls::psigmask = 2424; //; $tls::psigmask = 2832;
//; $tls::sigwait_mask = -10272; //; $tls::sigwait_mask = -9864;
//; $tls::psigwait_mask = 2428; //; $tls::psigwait_mask = 2836;
//; $tls::sigwait_info = -10268; //; $tls::sigwait_info = -9860;
//; $tls::psigwait_info = 2432; //; $tls::psigwait_info = 2840;
//; $tls::signal_arrived = -10264; //; $tls::signal_arrived = -9856;
//; $tls::psignal_arrived = 2436; //; $tls::psignal_arrived = 2844;
//; $tls::will_wait_for_signal = -10260; //; $tls::will_wait_for_signal = -9852;
//; $tls::pwill_wait_for_signal = 2440; //; $tls::pwill_wait_for_signal = 2848;
//; $tls::thread_context = -10256; //; $tls::thread_context = -9848;
//; $tls::pthread_context = 2444; //; $tls::pthread_context = 2852;
//; $tls::thread_id = -10044; //; $tls::thread_id = -9636;
//; $tls::pthread_id = 2656; //; $tls::pthread_id = 3064;
//; $tls::infodata = -10040; //; $tls::infodata = -9632;
//; $tls::pinfodata = 2660; //; $tls::pinfodata = 3068;
//; $tls::tid = -9892; //; $tls::tid = -9484;
//; $tls::ptid = 2808; //; $tls::ptid = 3216;
//; $tls::_ctinfo = -9888; //; $tls::_ctinfo = -9480;
//; $tls::p_ctinfo = 2812; //; $tls::p_ctinfo = 3220;
//; $tls::andreas = -9884; //; $tls::andreas = -9476;
//; $tls::pandreas = 2816; //; $tls::pandreas = 3224;
//; $tls::pathbufs = -9880;
//; $tls::ppathbufs = 2820;
//; $tls::wq = -9472; //; $tls::wq = -9472;
//; $tls::pwq = 3228; //; $tls::pwq = 3228;
//; $tls::sig = -9444; //; $tls::sig = -9444;
@ -63,46 +61,44 @@
#define tls_locals (-12700) #define tls_locals (-12700)
#define tls_plocals (0) #define tls_plocals (0)
#define tls_local_clib (-11388) #define tls_local_clib (-10980)
#define tls_plocal_clib (1312) #define tls_plocal_clib (1720)
#define tls___dontuse (-11388) #define tls___dontuse (-10980)
#define tls_p__dontuse (1312) #define tls_p__dontuse (1720)
#define tls_func (-10300) #define tls_func (-9892)
#define tls_pfunc (2400) #define tls_pfunc (2808)
#define tls_saved_errno (-10296) #define tls_saved_errno (-9888)
#define tls_psaved_errno (2404) #define tls_psaved_errno (2812)
#define tls_sa_flags (-10292) #define tls_sa_flags (-9884)
#define tls_psa_flags (2408) #define tls_psa_flags (2816)
#define tls_oldmask (-10288) #define tls_oldmask (-9880)
#define tls_poldmask (2412) #define tls_poldmask (2820)
#define tls_deltamask (-10284) #define tls_deltamask (-9876)
#define tls_pdeltamask (2416) #define tls_pdeltamask (2824)
#define tls_errno_addr (-10280) #define tls_errno_addr (-9872)
#define tls_perrno_addr (2420) #define tls_perrno_addr (2828)
#define tls_sigmask (-10276) #define tls_sigmask (-9868)
#define tls_psigmask (2424) #define tls_psigmask (2832)
#define tls_sigwait_mask (-10272) #define tls_sigwait_mask (-9864)
#define tls_psigwait_mask (2428) #define tls_psigwait_mask (2836)
#define tls_sigwait_info (-10268) #define tls_sigwait_info (-9860)
#define tls_psigwait_info (2432) #define tls_psigwait_info (2840)
#define tls_signal_arrived (-10264) #define tls_signal_arrived (-9856)
#define tls_psignal_arrived (2436) #define tls_psignal_arrived (2844)
#define tls_will_wait_for_signal (-10260) #define tls_will_wait_for_signal (-9852)
#define tls_pwill_wait_for_signal (2440) #define tls_pwill_wait_for_signal (2848)
#define tls_thread_context (-10256) #define tls_thread_context (-9848)
#define tls_pthread_context (2444) #define tls_pthread_context (2852)
#define tls_thread_id (-10044) #define tls_thread_id (-9636)
#define tls_pthread_id (2656) #define tls_pthread_id (3064)
#define tls_infodata (-10040) #define tls_infodata (-9632)
#define tls_pinfodata (2660) #define tls_pinfodata (3068)
#define tls_tid (-9892) #define tls_tid (-9484)
#define tls_ptid (2808) #define tls_ptid (3216)
#define tls__ctinfo (-9888) #define tls__ctinfo (-9480)
#define tls_p_ctinfo (2812) #define tls_p_ctinfo (3220)
#define tls_andreas (-9884) #define tls_andreas (-9476)
#define tls_pandreas (2816) #define tls_pandreas (3224)
#define tls_pathbufs (-9880)
#define tls_ppathbufs (2820)
#define tls_wq (-9472) #define tls_wq (-9472)
#define tls_pwq (3228) #define tls_pwq (3228)
#define tls_sig (-9444) #define tls_sig (-9444)

View File

@ -3,46 +3,44 @@
//; $tls::start_offset = -12800; //; $tls::start_offset = -12800;
//; $tls::locals = -12800; //; $tls::locals = -12800;
//; $tls::plocals = 0; //; $tls::plocals = 0;
//; $tls::local_clib = -11432; //; $tls::local_clib = -10624;
//; $tls::plocal_clib = 1368; //; $tls::plocal_clib = 2176;
//; $tls::__dontuse = -11432; //; $tls::__dontuse = -10624;
//; $tls::p__dontuse = 1368; //; $tls::p__dontuse = 2176;
//; $tls::func = -9544; //; $tls::func = -8736;
//; $tls::pfunc = 3256; //; $tls::pfunc = 4064;
//; $tls::saved_errno = -9536; //; $tls::saved_errno = -8728;
//; $tls::psaved_errno = 3264; //; $tls::psaved_errno = 4072;
//; $tls::sa_flags = -9532; //; $tls::sa_flags = -8724;
//; $tls::psa_flags = 3268; //; $tls::psa_flags = 4076;
//; $tls::oldmask = -9528; //; $tls::oldmask = -8720;
//; $tls::poldmask = 3272; //; $tls::poldmask = 4080;
//; $tls::deltamask = -9520; //; $tls::deltamask = -8712;
//; $tls::pdeltamask = 3280; //; $tls::pdeltamask = 4088;
//; $tls::errno_addr = -9512; //; $tls::errno_addr = -8704;
//; $tls::perrno_addr = 3288; //; $tls::perrno_addr = 4096;
//; $tls::sigmask = -9504; //; $tls::sigmask = -8696;
//; $tls::psigmask = 3296; //; $tls::psigmask = 4104;
//; $tls::sigwait_mask = -9496; //; $tls::sigwait_mask = -8688;
//; $tls::psigwait_mask = 3304; //; $tls::psigwait_mask = 4112;
//; $tls::sigwait_info = -9488; //; $tls::sigwait_info = -8680;
//; $tls::psigwait_info = 3312; //; $tls::psigwait_info = 4120;
//; $tls::signal_arrived = -9480; //; $tls::signal_arrived = -8672;
//; $tls::psignal_arrived = 3320; //; $tls::psignal_arrived = 4128;
//; $tls::will_wait_for_signal = -9472; //; $tls::will_wait_for_signal = -8664;
//; $tls::pwill_wait_for_signal = 3328; //; $tls::pwill_wait_for_signal = 4136;
//; $tls::thread_context = -9464; //; $tls::thread_context = -8656;
//; $tls::pthread_context = 3336; //; $tls::pthread_context = 4144;
//; $tls::thread_id = -8632; //; $tls::thread_id = -7824;
//; $tls::pthread_id = 4168; //; $tls::pthread_id = 4976;
//; $tls::infodata = -8628; //; $tls::infodata = -7820;
//; $tls::pinfodata = 4172; //; $tls::pinfodata = 4980;
//; $tls::tid = -8480; //; $tls::tid = -7672;
//; $tls::ptid = 4320; //; $tls::ptid = 5128;
//; $tls::_ctinfo = -8472; //; $tls::_ctinfo = -7664;
//; $tls::p_ctinfo = 4328; //; $tls::p_ctinfo = 5136;
//; $tls::andreas = -8464; //; $tls::andreas = -7656;
//; $tls::pandreas = 4336; //; $tls::pandreas = 5144;
//; $tls::pathbufs = -8456;
//; $tls::ppathbufs = 4344;
//; $tls::wq = -7648; //; $tls::wq = -7648;
//; $tls::pwq = 5152; //; $tls::pwq = 5152;
//; $tls::sig = -7600; //; $tls::sig = -7600;
@ -63,46 +61,44 @@
#define tls_locals (-12800) #define tls_locals (-12800)
#define tls_plocals (0) #define tls_plocals (0)
#define tls_local_clib (-11432) #define tls_local_clib (-10624)
#define tls_plocal_clib (1368) #define tls_plocal_clib (2176)
#define tls___dontuse (-11432) #define tls___dontuse (-10624)
#define tls_p__dontuse (1368) #define tls_p__dontuse (2176)
#define tls_func (-9544) #define tls_func (-8736)
#define tls_pfunc (3256) #define tls_pfunc (4064)
#define tls_saved_errno (-9536) #define tls_saved_errno (-8728)
#define tls_psaved_errno (3264) #define tls_psaved_errno (4072)
#define tls_sa_flags (-9532) #define tls_sa_flags (-8724)
#define tls_psa_flags (3268) #define tls_psa_flags (4076)
#define tls_oldmask (-9528) #define tls_oldmask (-8720)
#define tls_poldmask (3272) #define tls_poldmask (4080)
#define tls_deltamask (-9520) #define tls_deltamask (-8712)
#define tls_pdeltamask (3280) #define tls_pdeltamask (4088)
#define tls_errno_addr (-9512) #define tls_errno_addr (-8704)
#define tls_perrno_addr (3288) #define tls_perrno_addr (4096)
#define tls_sigmask (-9504) #define tls_sigmask (-8696)
#define tls_psigmask (3296) #define tls_psigmask (4104)
#define tls_sigwait_mask (-9496) #define tls_sigwait_mask (-8688)
#define tls_psigwait_mask (3304) #define tls_psigwait_mask (4112)
#define tls_sigwait_info (-9488) #define tls_sigwait_info (-8680)
#define tls_psigwait_info (3312) #define tls_psigwait_info (4120)
#define tls_signal_arrived (-9480) #define tls_signal_arrived (-8672)
#define tls_psignal_arrived (3320) #define tls_psignal_arrived (4128)
#define tls_will_wait_for_signal (-9472) #define tls_will_wait_for_signal (-8664)
#define tls_pwill_wait_for_signal (3328) #define tls_pwill_wait_for_signal (4136)
#define tls_thread_context (-9464) #define tls_thread_context (-8656)
#define tls_pthread_context (3336) #define tls_pthread_context (4144)
#define tls_thread_id (-8632) #define tls_thread_id (-7824)
#define tls_pthread_id (4168) #define tls_pthread_id (4976)
#define tls_infodata (-8628) #define tls_infodata (-7820)
#define tls_pinfodata (4172) #define tls_pinfodata (4980)
#define tls_tid (-8480) #define tls_tid (-7672)
#define tls_ptid (4320) #define tls_ptid (5128)
#define tls__ctinfo (-8472) #define tls__ctinfo (-7664)
#define tls_p_ctinfo (4328) #define tls_p_ctinfo (5136)
#define tls_andreas (-8464) #define tls_andreas (-7656)
#define tls_pandreas (4336) #define tls_pandreas (5144)
#define tls_pathbufs (-8456)
#define tls_ppathbufs (4344)
#define tls_wq (-7648) #define tls_wq (-7648)
#define tls_pwq (5152) #define tls_pwq (5152)
#define tls_sig (-7600) #define tls_sig (-7600)