2009-01-07 17:19:38 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
|
|
|
|
#ifndef SYS_set_thread_area
|
|
|
|
#define SYS_set_thread_area 243
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int main (void)
|
|
|
|
{
|
2010-07-29 19:15:28 +04:00
|
|
|
unsigned long tp, old_tp;
|
2009-01-07 17:19:38 +03:00
|
|
|
int ret;
|
|
|
|
|
2010-07-29 19:15:28 +04:00
|
|
|
asm volatile ("move $pid,%0" : "=r" (old_tp));
|
|
|
|
old_tp &= ~0xff;
|
|
|
|
|
2009-01-07 17:19:38 +03:00
|
|
|
ret = syscall (SYS_set_thread_area, 0xf0);
|
|
|
|
if (ret != -1 || errno != EINVAL) {
|
2010-07-29 19:15:28 +04:00
|
|
|
syscall (SYS_set_thread_area, old_tp);
|
2009-01-07 17:19:38 +03:00
|
|
|
perror ("Invalid thread area accepted:");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = syscall (SYS_set_thread_area, 0xeddeed00);
|
|
|
|
if (ret != 0) {
|
|
|
|
perror ("Valid thread area not accepted: ");
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
|
2010-07-29 19:15:28 +04:00
|
|
|
asm volatile ("move $pid,%0" : "=r" (tp));
|
2009-01-07 17:19:38 +03:00
|
|
|
tp &= ~0xff;
|
2010-07-29 19:15:28 +04:00
|
|
|
syscall (SYS_set_thread_area, old_tp);
|
2009-01-07 17:19:38 +03:00
|
|
|
|
|
|
|
if (tp != 0xeddeed00) {
|
2018-12-14 01:37:37 +03:00
|
|
|
* (volatile int *) 0 = 0;
|
2009-01-07 17:19:38 +03:00
|
|
|
perror ("tls2");
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
|
|
|
|
printf ("pass\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|