Browse Source

ensure the compiler does not move around thread-register-based reads

if gcc decided to move this across a conditional that checks validity
of the thread register, an invalid thread-register-based read could be
performed and raise sigsegv.
rs-1.0
Rich Felker 15 years ago
parent
commit
8426a99048
  1. 2
      arch/i386/pthread_arch.h
  2. 2
      arch/x86_64/pthread_arch.h

2
arch/i386/pthread_arch.h

@ -1,7 +1,7 @@
static inline struct pthread *__pthread_self()
{
struct pthread *self;
__asm__ ("movl %%gs:0,%0" : "=r" (self) );
__asm__ __volatile__ ("movl %%gs:0,%0" : "=r" (self) );
return self;
}

2
arch/x86_64/pthread_arch.h

@ -1,7 +1,7 @@
static inline struct pthread *__pthread_self()
{
struct pthread *self;
__asm__ ("movq %%fs:0,%0" : "=r" (self) );
__asm__ __volatile__ ("movq %%fs:0,%0" : "=r" (self) );
return self;
}

Loading…
Cancel
Save