Exemplo n.º 1
0
void read_chunk_tls(void *fptr, int action)
{
    struct user_desc u;
    int ret;

    read_bit(fptr, &u, sizeof(struct user_desc));

    if (!u.base_addr)
	return;

    if (action & ACTION_PRINT)
	fprintf(stderr, "TLS entry (%d): base_addr = 0x%lx", 
		u.entry_number, u.base_addr);

    if (!(action & ACTION_LOAD))
	return;

    if (!emulate_tls) {
	ret = set_thread_area(NULL);
	if (ret == -1) /* some libcs return the actual errno instead of -1 */
	    ret = -errno;
	if (ret == -ENOSYS) {
	    /* We are not a TLS capable system. Turn on TLS emulation voodoo. */
	    emulate_tls = 1;

	    /* We'll need write access to the code segments to do this. */
	    extra_prot_flags |= PROT_WRITE;
	}
    }

    if (emulate_tls)
	tls_base_address = u.base_addr;
    else
	syscall_check(set_thread_area(&u), 0, "set_thread_area");
}
Exemplo n.º 2
0
int prog(void)
{
  unsigned long fs;
  struct user_desc ta;

  fs = get_fs();
  printf("FS: %lu\n", fs);

  ta.entry_number = 0;
  get_thread_area(&ta); 
  printf("TA: entry=%d, base=%lu, length=%d\n", ta.entry_number, ta.base_addr, ta.limit);

  ta.entry_number = 1;
  get_thread_area(&ta); 
  printf("TA: entry=%d, base=%lu, length=%d\n", ta.entry_number, ta.base_addr, ta.limit);

  ta.entry_number = 2;
  get_thread_area(&ta); 
  printf("TA: entry=%d, base=%lu, length=%d\n", ta.entry_number, ta.base_addr, ta.limit);

  ta.entry_number = 3;
  get_thread_area(&ta); 
  printf("TA: entry=%d, base=%lu, length=%d\n", ta.entry_number, ta.base_addr, ta.limit);

  ta.entry_number = 3;
  ta.base_addr = 0x10000;
  ta.limit = 100;
  set_thread_area(&ta); 

  memset(&ta, 0, sizeof(struct user_desc));
  ta.entry_number = 3;
  get_thread_area(&ta); 
  printf("TA: entry=%d, base=%lu, length=%d\n", ta.entry_number, ta.base_addr, ta.limit);

  ta.entry_number = 2;
  get_thread_area(&ta); 
  printf("TA: entry=%d, base=%lu, length=%d\n", ta.entry_number, ta.base_addr, ta.limit);


  usleep(500000);
}