summaryrefslogtreecommitdiff
path: root/sysdeps/mach/hurd/i386
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2016-08-20 20:46:16 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-08-20 20:46:16 +0200
commit0ade236f193778d89a77d8f8b4a99cabdf8fad93 (patch)
tree327093054cca8d7893cc1d65ed5b879d0743eb5e /sysdeps/mach/hurd/i386
parent8a8b81e864bf452b579975b3a622780fb229968c (diff)
parentf76453c31593957fec1a99b986bfa5506618b79c (diff)
Merge commit 'refs/top-bases/t/tls_thread_leak' into t/tls_thread_leak
Diffstat (limited to 'sysdeps/mach/hurd/i386')
-rw-r--r--sysdeps/mach/hurd/i386/____longjmp_chk.S2
-rw-r--r--sysdeps/mach/hurd/i386/bits/sigcontext.h2
-rw-r--r--sysdeps/mach/hurd/i386/exc2signal.c2
-rw-r--r--sysdeps/mach/hurd/i386/init-first.c7
-rw-r--r--sysdeps/mach/hurd/i386/intr-msg.h8
-rw-r--r--sysdeps/mach/hurd/i386/ioperm.c2
-rw-r--r--sysdeps/mach/hurd/i386/longjmp-ts.c2
-rw-r--r--sysdeps/mach/hurd/i386/sigcontextinfo.h2
-rw-r--r--sysdeps/mach/hurd/i386/sigreturn.c2
-rw-r--r--sysdeps/mach/hurd/i386/static-start.S2
-rw-r--r--sysdeps/mach/hurd/i386/sys/io.h2
-rw-r--r--sysdeps/mach/hurd/i386/tls.h122
-rw-r--r--sysdeps/mach/hurd/i386/trampoline.c3
13 files changed, 84 insertions, 74 deletions
diff --git a/sysdeps/mach/hurd/i386/____longjmp_chk.S b/sysdeps/mach/hurd/i386/____longjmp_chk.S
index 666465e9e9..0fa685e3fb 100644
--- a/sysdeps/mach/hurd/i386/____longjmp_chk.S
+++ b/sysdeps/mach/hurd/i386/____longjmp_chk.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2014 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/mach/hurd/i386/bits/sigcontext.h b/sysdeps/mach/hurd/i386/bits/sigcontext.h
index c51a94ef1a..780779fdce 100644
--- a/sysdeps/mach/hurd/i386/bits/sigcontext.h
+++ b/sysdeps/mach/hurd/i386/bits/sigcontext.h
@@ -1,5 +1,5 @@
/* Machine-dependent signal context structure for GNU Hurd. i386 version.
- Copyright (C) 1991-2014 Free Software Foundation, Inc.
+ Copyright (C) 1991-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/mach/hurd/i386/exc2signal.c b/sysdeps/mach/hurd/i386/exc2signal.c
index b67acff08d..74dda77901 100644
--- a/sysdeps/mach/hurd/i386/exc2signal.c
+++ b/sysdeps/mach/hurd/i386/exc2signal.c
@@ -1,5 +1,5 @@
/* Translate Mach exception codes into signal numbers. i386 version.
- Copyright (C) 1991-2014 Free Software Foundation, Inc.
+ Copyright (C) 1991-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index fc355ed6c3..b9bae324d1 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -1,5 +1,5 @@
/* Initialization code run first thing by the ELF startup code. For i386/Hurd.
- Copyright (C) 1995-2014 Free Software Foundation, Inc.
+ Copyright (C) 1995-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -72,6 +72,11 @@ posixland_init (int argc, char **argv, char **envp)
/* Set the FPU control word to the proper default value. */
__setfpucw (__fpu_control);
}
+ else
+ {
+ /* Initialize data structures so the additional libc can do RPCs. */
+ __mach_init ();
+ }
/* Save the command-line arguments. */
__libc_argc = argc;
diff --git a/sysdeps/mach/hurd/i386/intr-msg.h b/sysdeps/mach/hurd/i386/intr-msg.h
index 452c3ed725..0be995c53b 100644
--- a/sysdeps/mach/hurd/i386/intr-msg.h
+++ b/sysdeps/mach/hurd/i386/intr-msg.h
@@ -1,5 +1,5 @@
/* Machine-dependent details of interruptible RPC messaging. i386 version.
- Copyright (C) 1995-2014 Free Software Foundation, Inc.
+ Copyright (C) 1995-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -33,9 +33,9 @@
"_hurd_intr_rpc_msg_do_trap: lcall $7, $0 # status in %0\n" \
"_hurd_intr_rpc_msg_in_trap: movl %%ecx, %%esp\n" \
"_hurd_intr_rpc_msg_sp_restored:" \
- : "=a" (err), "=m" (option), "=m" (timeout) \
- : "m" ((&msg)[-1]), "1" (option), "2" (timeout) \
- : "%ecx"); \
+ : "=a" (err), "+m" (option), "+m" (timeout) \
+ : "m" ((&msg)[-1]) \
+ : "ecx"); \
err; \
})
diff --git a/sysdeps/mach/hurd/i386/ioperm.c b/sysdeps/mach/hurd/i386/ioperm.c
index abd0051c6c..6dc2b5de64 100644
--- a/sysdeps/mach/hurd/i386/ioperm.c
+++ b/sysdeps/mach/hurd/i386/ioperm.c
@@ -1,5 +1,5 @@
/* Access to hardware i/o ports. Hurd/x86 version.
- Copyright (C) 2002-2014 Free Software Foundation, Inc.
+ Copyright (C) 2002-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/mach/hurd/i386/longjmp-ts.c b/sysdeps/mach/hurd/i386/longjmp-ts.c
index f78aa772f0..c02e9a5e0f 100644
--- a/sysdeps/mach/hurd/i386/longjmp-ts.c
+++ b/sysdeps/mach/hurd/i386/longjmp-ts.c
@@ -1,5 +1,5 @@
/* Perform a `longjmp' on a Mach thread_state. i386 version.
- Copyright (C) 1991-2014 Free Software Foundation, Inc.
+ Copyright (C) 1991-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/mach/hurd/i386/sigcontextinfo.h b/sysdeps/mach/hurd/i386/sigcontextinfo.h
index 27b548e73f..ca8f57710a 100644
--- a/sysdeps/mach/hurd/i386/sigcontextinfo.h
+++ b/sysdeps/mach/hurd/i386/sigcontextinfo.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-2014 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/mach/hurd/i386/sigreturn.c b/sysdeps/mach/hurd/i386/sigreturn.c
index 6dba161d7c..1d7ccc39f0 100644
--- a/sysdeps/mach/hurd/i386/sigreturn.c
+++ b/sysdeps/mach/hurd/i386/sigreturn.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2014 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/mach/hurd/i386/static-start.S b/sysdeps/mach/hurd/i386/static-start.S
index 22bb84c219..6f8d3d59c5 100644
--- a/sysdeps/mach/hurd/i386/static-start.S
+++ b/sysdeps/mach/hurd/i386/static-start.S
@@ -1,5 +1,5 @@
/* Startup code for statically linked Hurd/i386 binaries.
- Copyright (C) 1998-2014 Free Software Foundation, Inc.
+ Copyright (C) 1998-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/mach/hurd/i386/sys/io.h b/sysdeps/mach/hurd/i386/sys/io.h
index 6ad2d94ded..28fe01fcda 100644
--- a/sysdeps/mach/hurd/i386/sys/io.h
+++ b/sysdeps/mach/hurd/i386/sys/io.h
@@ -1,5 +1,5 @@
/* Access to hardware i/o ports. GNU/x86 version.
- Copyright (C) 2002-2014 Free Software Foundation, Inc.
+ Copyright (C) 2002-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h
index 8b7ac200f4..e2e454cabf 100644
--- a/sysdeps/mach/hurd/i386/tls.h
+++ b/sysdeps/mach/hurd/i386/tls.h
@@ -1,5 +1,5 @@
/* Definitions for thread-local data handling. Hurd/i386 version.
- Copyright (C) 2003-2014 Free Software Foundation, Inc.
+ Copyright (C) 2003-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,9 +23,44 @@
/* Some things really need not be machine-dependent. */
#include <sysdeps/mach/hurd/tls.h>
+
+#ifndef __ASSEMBLER__
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+
+/* Type of the TCB. */
+typedef struct
+{
+ void *tcb; /* Points to this structure. */
+ dtv_t *dtv; /* Vector of pointers to TLS data. */
+ thread_t self; /* This thread's control port. */
+ int multiple_threads;
+ uintptr_t sysinfo;
+ uintptr_t stack_guard;
+ uintptr_t pointer_guard;
+ int gscope_flag;
+ int private_futex;
+ /* Reservation of some values for the TM ABI. */
+ void *__private_tm[4];
+ /* GCC split stack support. */
+ void *__private_ss;
+} tcbhead_t;
+#endif
+
+
/* The TCB can have any size and the memory following the address the
thread pointer points to is unspecified. Allocate the TCB there. */
#define TLS_TCB_AT_TP 1
+#define TLS_DTV_AT_TP 0
#ifndef __ASSEMBLER__
@@ -55,80 +90,51 @@
static inline const char * __attribute__ ((unused))
-_hurd_tls_init (tcbhead_t *tcb, int secondcall)
+_hurd_tls_init (tcbhead_t *tcb)
{
HURD_TLS_DESC_DECL (desc, tcb);
thread_t self = __mach_thread_self ();
const char *msg = NULL;
- if (!secondcall)
+ /* This field is used by TLS accesses to get our "thread pointer"
+ from the TLS point of view. */
+ tcb->tcb = tcb;
+
+ /* Get the first available selector. */
+ int sel = -1;
+ error_t err = __i386_set_gdt (self, &sel, desc);
+ if (err == MIG_BAD_ID)
{
- /* This field is used by TLS accesses to get our "thread pointer"
- from the TLS point of view. */
- tcb->tcb = tcb;
-
- /* Get the first available selector. */
- int sel = -1;
- error_t err = __i386_set_gdt (self, &sel, desc);
- if (err == MIG_BAD_ID)
- {
- /* Old kernel, use a per-thread LDT. */
- sel = 0x27;
- err = __i386_set_ldt (self, sel, &desc, 1);
- assert_perror (err);
- if (err)
- {
- msg = "i386_set_ldt failed";
- goto out;
- }
- }
- else if (err)
- {
- assert_perror (err); /* Separate from above with different line #. */
- msg = "i386_set_gdt failed";
- goto out;
- }
-
- /* Now install the new selector. */
- asm volatile ("mov %w0, %%gs" :: "q" (sel));
+ /* Old kernel, use a per-thread LDT. */
+ sel = 0x27;
+ err = __i386_set_ldt (self, sel, &desc, 1);
+ assert_perror (err);
+ if (err)
+ {
+ msg = "i386_set_ldt failed";
+ goto out;
+ }
}
- else
+ else if (err)
{
- /* Fetch the selector set by the first call. */
- int sel;
- asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0));
- if (__builtin_expect (sel, 0x50) & 4) /* LDT selector */
- {
- error_t err = __i386_set_ldt (self, sel, &desc, 1);
- assert_perror (err);
- if (err)
- {
- msg = "i386_set_ldt failed";
- goto out;
- }
- }
- else
- {
- error_t err = __i386_set_gdt (self, &sel, desc);
- assert_perror (err);
- if (err)
- {
- msg = "i386_set_gdt failed";
- goto out;
- }
- }
+ assert_perror (err); /* Separate from above with different line #. */
+ msg = "i386_set_gdt failed";
+ goto out;
}
+ /* Now install the new selector. */
+ asm volatile ("mov %w0, %%gs" :: "q" (sel));
+
out:
__mach_port_deallocate (__mach_task_self (), self);
- return msg;
+ return 0;
}
/* Code to initially initialize the thread pointer. This might need
special attention since 'errno' is not yet available and if the
operation can cause a failure 'errno' must not be touched. */
-# define TLS_INIT_TP(descr, secondcall) \
- _hurd_tls_init ((tcbhead_t *) (descr), (secondcall))
+# define TLS_INIT_TP(descr) \
+ _hurd_tls_init ((tcbhead_t *) (descr))
/* Return the TCB address of the current thread. */
# define THREAD_SELF \
diff --git a/sysdeps/mach/hurd/i386/trampoline.c b/sysdeps/mach/hurd/i386/trampoline.c
index d4a839304b..2dffd1382c 100644
--- a/sysdeps/mach/hurd/i386/trampoline.c
+++ b/sysdeps/mach/hurd/i386/trampoline.c
@@ -1,5 +1,5 @@
/* Set thread_state for sighandler, and sigcontext to recover. i386 version.
- Copyright (C) 1994-2014 Free Software Foundation, Inc.
+ Copyright (C) 1994-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -35,7 +35,6 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
void trampoline (void);
void rpc_wait_trampoline (void);
void firewall (void);
- extern const void _hurd_intr_rpc_msg_in_trap;
extern const void _hurd_intr_rpc_msg_cx_sp;
extern const void _hurd_intr_rpc_msg_sp_restored;
void *volatile sigsp;