This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch hjl/pr21609/master created. glibc-2.25-672-g58b6dc8
- From: hjl at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 4 Jul 2017 14:18:06 -0000
- Subject: GNU C Library master sources branch hjl/pr21609/master created. glibc-2.25-672-g58b6dc8
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, hjl/pr21609/master has been created
at 58b6dc823b3c400b2923dd4e5fd62246a67fa3ab (commit)
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=58b6dc823b3c400b2923dd4e5fd62246a67fa3ab
commit 58b6dc823b3c400b2923dd4e5fd62246a67fa3ab
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Jul 4 07:17:49 2017 -0700
Updated
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index 6835346..5aba33b 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -827,7 +827,6 @@ rtld_hidden_proto (__tls_get_addr)
rtld_hidden_def (__tls_get_addr)
#endif
-#ifndef __tls_get_addr_slow
/* The generic dynamic and local dynamic model cannot be used in
statically linked applications. */
void *
@@ -846,7 +845,6 @@ __tls_get_addr (GET_ADDR_ARGS)
return (char *) p + GET_ADDR_OFFSET;
}
#endif
-#endif
/* Look up the module's TLS block as for __tls_get_addr,
diff --git a/sysdeps/x86_64/dl-tls.c b/sysdeps/x86_64/dl-tls.c
index 5006dda..567224e 100644
--- a/sysdeps/x86_64/dl-tls.c
+++ b/sysdeps/x86_64/dl-tls.c
@@ -23,15 +23,17 @@
# include <dl-tls.h>
-/* Don't define __tls_get_addr in elf/dl-tls.c. */
-# define __tls_get_addr __redirect___tls_get_addr
-# define __tls_get_addr_slow
+/* Define __tls_get_addr within elf/dl-tls.c under a different
+ name. */
+extern __typeof__ (__tls_get_addr) __tls_get_addr_default;
+
+# define __tls_get_addr __tls_get_addr_default
# include <elf/dl-tls.c>
-# undef __tls_get_addr_slow
# undef __tls_get_addr
-/* The generic dynamic and local dynamic model cannot be used in
- statically linked applications. */
+hidden_ver (__tls_get_addr_default, __tls_get_addr)
+
+/* Only handle slow paths for __tls_get_addr. */
attribute_hidden
void *
__tls_get_addr_slow (GET_ADDR_ARGS)
diff --git a/sysdeps/x86_64/tls_get_addr.S b/sysdeps/x86_64/tls_get_addr.S
index d4f1a33..8268c7f 100644
--- a/sysdeps/x86_64/tls_get_addr.S
+++ b/sysdeps/x86_64/tls_get_addr.S
@@ -52,6 +52,4 @@ ENTRY (__tls_get_addr)
cfi_def_cfa (%rsp, 8)
ret
END (__tls_get_addr)
-
-rtld_hidden_def (__tls_get_addr)
#endif /* SHARED */
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=0c239bea066f5433cec17f0524c29ca21e8fb4cc
commit 0c239bea066f5433cec17f0524c29ca21e8fb4cc
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Jul 4 07:03:13 2017 -0700
x86-64: Align the stack in __tls_get_addr [BZ #21609]
This change forces realignment of the stack pointer in __tls_get_addr, so
that binaries compiled by GCCs older than GCC 4.9:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066
continue to work even if vector instructions are used in glibc which
require the ABI stack realignment.
__tls_get_addr_slow is added to handle the slow paths in the default
implementation of__tls_get_addr in elf/dl-tls.c. The new __tls_get_addr
calls __tls_get_addr_slow after realigning the stack.
2017-07-03 Florian Weimer <fweimer@redhat.com>
H.J. Lu <hongjiu.lu@intel.com>
[BZ #21609]
* sysdeps/x86_64/Makefile (sysdep-dl-routines): Add tls_get_addr.
(gen-as-const-headers): Add rtld-offsets.sym.
* sysdeps/x86_64/dl-tls.c: New file.
* sysdeps/x86_64/rtld-offsets.sym: Likwise.
* sysdeps/x86_64/tls_get_addr.S: Likewise.
* sysdeps/x86_64/dl-tls.h: Add multiple inclusion guards.
* sysdeps/x86_64/tlsdesc.sym (TI_MODULE_OFFSET): New.
(TI_OFFSET_OFFSET): Likwise.
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index 5aba33b..6835346 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -827,6 +827,7 @@ rtld_hidden_proto (__tls_get_addr)
rtld_hidden_def (__tls_get_addr)
#endif
+#ifndef __tls_get_addr_slow
/* The generic dynamic and local dynamic model cannot be used in
statically linked applications. */
void *
@@ -845,6 +846,7 @@ __tls_get_addr (GET_ADDR_ARGS)
return (char *) p + GET_ADDR_OFFSET;
}
#endif
+#endif
/* Look up the module's TLS block as for __tls_get_addr,
diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile
index 0750410..132470d 100644
--- a/sysdeps/x86_64/Makefile
+++ b/sysdeps/x86_64/Makefile
@@ -29,8 +29,6 @@ CFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
sysdep-dl-routines += tlsdesc dl-tlsdesc tls_get_addr
-CFLAGS-tls_get_addr.c = -maccumulate-outgoing-args
-
tests += ifuncmain8
modules-names += ifuncmod8
@@ -122,5 +120,5 @@ endif
endif
ifeq ($(subdir),csu)
-gen-as-const-headers += tlsdesc.sym
+gen-as-const-headers += tlsdesc.sym rtld-offsets.sym
endif
diff --git a/sysdeps/x86_64/dl-tls.c b/sysdeps/x86_64/dl-tls.c
index dad9080..5006dda 100644
--- a/sysdeps/x86_64/dl-tls.c
+++ b/sysdeps/x86_64/dl-tls.c
@@ -23,15 +23,26 @@
# include <dl-tls.h>
-/* Define __tls_get_addr within elf/dl-tls.c under a different
- name. */
-extern __typeof__ (__tls_get_addr) __tls_get_addr_default;
-
-# define __tls_get_addr __tls_get_addr_default
+/* Don't define __tls_get_addr in elf/dl-tls.c. */
+# define __tls_get_addr __redirect___tls_get_addr
+# define __tls_get_addr_slow
# include <elf/dl-tls.c>
+# undef __tls_get_addr_slow
# undef __tls_get_addr
-hidden_ver (__tls_get_addr_default, __tls_get_addr)
+/* The generic dynamic and local dynamic model cannot be used in
+ statically linked applications. */
+attribute_hidden
+void *
+__tls_get_addr_slow (GET_ADDR_ARGS)
+{
+ dtv_t *dtv = THREAD_DTV ();
+
+ if (__glibc_unlikely (dtv[0].counter != GL(dl_tls_generation)))
+ return update_get_addr (GET_ADDR_PARAM);
+
+ return tls_get_addr_tail (GET_ADDR_PARAM, dtv, NULL);
+}
#else
/* No compatibility symbol needed. */
diff --git a/sysdeps/x86_64/rtld-offsets.sym b/sysdeps/x86_64/rtld-offsets.sym
new file mode 100644
index 0000000..fd41b51
--- /dev/null
+++ b/sysdeps/x86_64/rtld-offsets.sym
@@ -0,0 +1,6 @@
+#define SHARED
+#include <ldsodefs.h>
+
+--
+
+GL_TLS_GENERATION_OFFSET offsetof (struct rtld_global, _dl_tls_generation)
diff --git a/sysdeps/x86_64/tls_get_addr.S b/sysdeps/x86_64/tls_get_addr.S
new file mode 100644
index 0000000..d4f1a33
--- /dev/null
+++ b/sysdeps/x86_64/tls_get_addr.S
@@ -0,0 +1,57 @@
+/* Stack-aligning implementation of __tls_get_addr. x86-64 version.
+ Copyright (C) 2017 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef SHARED
+
+# include <sysdep.h>
+# include "tlsdesc.h"
+# include "rtld-offsets.h"
+
+/* See __tls_get_addr and __tls_get_addr_slow in dl-tls.c. This function
+ call __tls_get_addr_slow on both slow paths. It realigns the stack
+ before the call to work around GCC PR58066. */
+
+ENTRY (__tls_get_addr)
+ movq %fs:DTV_OFFSET, %rdx
+ movq GL_TLS_GENERATION_OFFSET+_rtld_local(%rip), %rax
+ cmpq %rax, (%rdx) /* GL(dl_tls_generation) == dtv[0].counter */
+ jne 1f
+ movq TI_MODULE_OFFSET(%rdi), %rax
+ salq $4, %rax
+ movq (%rdx,%rax), %rax /* dtv[ti->ti_module] */
+ cmpq $-1, %rax
+ je 1f
+ addq TI_OFFSET_OFFSET(%rdi), %rax
+ ret
+1:
+ /* On the slow path, align the stack. */
+ pushq %rbp
+ cfi_def_cfa_offset (16)
+ cfi_offset (%rbp, -16)
+ movq %rsp, %rbp
+ cfi_def_cfa_register (%rbp)
+ andq $-16, %rsp
+ call __tls_get_addr_slow
+ movq %rbp, %rsp
+ popq %rbp
+ cfi_def_cfa (%rsp, 8)
+ ret
+END (__tls_get_addr)
+
+rtld_hidden_def (__tls_get_addr)
+#endif /* SHARED */
diff --git a/sysdeps/x86_64/tls_get_addr.c b/sysdeps/x86_64/tls_get_addr.c
deleted file mode 100644
index 4224d55..0000000
--- a/sysdeps/x86_64/tls_get_addr.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* __tls_get_addr. x86-64 version.
- Copyright (C) 2017 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#ifdef SHARED
-/* Work around GCC PR58066, due to which __tls_get_addr may be called
- with an unaligned stack. The compat implementation is in
- tls_get_addr-compat.S. */
-
-# include <dl-tls.h>
-
-extern __typeof__ (__tls_get_addr) __tls_get_addr_default
- attribute_hidden;
-
-__attribute__ ((force_align_arg_pointer))
-void *
-__tls_get_addr (tls_index *ti)
-{
- return __tls_get_addr_default (ti);
-}
-#endif
diff --git a/sysdeps/x86_64/tlsdesc.sym b/sysdeps/x86_64/tlsdesc.sym
index 3385497..fc897ab 100644
--- a/sysdeps/x86_64/tlsdesc.sym
+++ b/sysdeps/x86_64/tlsdesc.sym
@@ -15,3 +15,6 @@ TLSDESC_ARG offsetof(struct tlsdesc, arg)
TLSDESC_GEN_COUNT offsetof(struct tlsdesc_dynamic_arg, gen_count)
TLSDESC_MODID offsetof(struct tlsdesc_dynamic_arg, tlsinfo.ti_module)
TLSDESC_MODOFF offsetof(struct tlsdesc_dynamic_arg, tlsinfo.ti_offset)
+
+TI_MODULE_OFFSET offsetof(tls_index, ti_module)
+TI_OFFSET_OFFSET offsetof(tls_index, ti_offset)
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f53c479a3847accbd48aaaa4b39346e07d7a6cf4
commit f53c479a3847accbd48aaaa4b39346e07d7a6cf4
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Jul 4 05:51:55 2017 -0700
x86-64: Align the stack in __tls_get_addr [BZ #21609]
This change forces realignment of the stack pointer in __tls_get_addr, so
that old GCC-compiled binaries continue to work even if vector instructions
are used in glibc which require the ABI stack realignment.
The implementation of __tls_get_addr calls the default implementation
(from elf/dl-tls.c, now calls __tls_get_addr_default) after realigning
the stack. Internal calls go directly to __tls_get_addr_default because
they do not need stack realignment.
2017-07-03 Florian Weimer <fweimer@redhat.com>
H.J. Lu <hongjiu.lu@intel.com>
[BZ #21609]
* sysdeps/x86_64/Makefile (sysdep-dl-routines): Add tls_get_addr.
(CFLAGS-tls_get_addr.c): New.
* sysdeps/x86_64/dl-tls.c: New file.
* sysdeps/x86_64/tls_get_addr.c: Likewise.
* sysdeps/x86_64/dl-tls.h: Add multiple inclusion guards.
diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile
index 5075c91..0750410 100644
--- a/sysdeps/x86_64/Makefile
+++ b/sysdeps/x86_64/Makefile
@@ -27,7 +27,9 @@ ifeq ($(subdir),elf)
CFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
-mno-mmx)
-sysdep-dl-routines += tlsdesc dl-tlsdesc
+sysdep-dl-routines += tlsdesc dl-tlsdesc tls_get_addr
+
+CFLAGS-tls_get_addr.c = -maccumulate-outgoing-args
tests += ifuncmain8
modules-names += ifuncmod8
diff --git a/sysdeps/x86_64/dl-tls.c b/sysdeps/x86_64/dl-tls.c
index 64fd391..dad9080 100644
--- a/sysdeps/x86_64/dl-tls.c
+++ b/sysdeps/x86_64/dl-tls.c
@@ -32,13 +32,6 @@ extern __typeof__ (__tls_get_addr) __tls_get_addr_default;
# undef __tls_get_addr
hidden_ver (__tls_get_addr_default, __tls_get_addr)
-
-__attribute__ ((force_align_arg_pointer))
-void *
-__tls_get_addr (tls_index *ti)
-{
- return __tls_get_addr_default (ti);
-}
#else
/* No compatibility symbol needed. */
diff --git a/sysdeps/x86_64/dl-tls.c b/sysdeps/x86_64/tls_get_addr.c
similarity index 71%
copy from sysdeps/x86_64/dl-tls.c
copy to sysdeps/x86_64/tls_get_addr.c
index 64fd391..4224d55 100644
--- a/sysdeps/x86_64/dl-tls.c
+++ b/sysdeps/x86_64/tls_get_addr.c
@@ -1,4 +1,4 @@
-/* Thread-local storage handling in the ELF dynamic linker. x86-64 version.
+/* __tls_get_addr. x86-64 version.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -23,15 +23,8 @@
# include <dl-tls.h>
-/* Define __tls_get_addr within elf/dl-tls.c under a different
- name. */
-extern __typeof__ (__tls_get_addr) __tls_get_addr_default;
-
-# define __tls_get_addr __tls_get_addr_default
-# include <elf/dl-tls.c>
-# undef __tls_get_addr
-
-hidden_ver (__tls_get_addr_default, __tls_get_addr)
+extern __typeof__ (__tls_get_addr) __tls_get_addr_default
+ attribute_hidden;
__attribute__ ((force_align_arg_pointer))
void *
@@ -39,9 +32,4 @@ __tls_get_addr (tls_index *ti)
{
return __tls_get_addr_default (ti);
}
-#else
-
-/* No compatibility symbol needed. */
-# include <elf/dl-tls.c>
-
#endif
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7bd9f666244ca837f443bff8b45dd4783a676d32
commit 7bd9f666244ca837f443bff8b45dd4783a676d32
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Jul 3 13:16:57 2017 -0700
x86-64: Align the stack in __tls_get_addr [BZ #21609]
This change forces realignment of the stack pointer in __tls_get_addr, so
that old GCC-compiled binaries continue to work even if vector instructions
are used in glibc which require the ABI stack realignment.
The implementation of __tls_get_addr calls the default implementation
(from elf/dl-tls.c, now calls __tls_get_addr_default) after realigning
the stack. Internal calls go directly to __tls_get_addr_default because
they do not need stack realignment.
2017-07-03 Florian Weimer <fweimer@redhat.com>
H.J. Lu <hongjiu.lu@intel.com>
[BZ #21609]
* sysdeps/x86_64/dl-tls.c: New file.
* sysdeps/x86_64/dl-tls.h: Add multiple inclusion guards.
diff --git a/sysdeps/x86_64/dl-tls.h b/sysdeps/x86_64/dl-tls.c
similarity index 52%
copy from sysdeps/x86_64/dl-tls.h
copy to sysdeps/x86_64/dl-tls.c
index 4a59d2a..64fd391 100644
--- a/sysdeps/x86_64/dl-tls.h
+++ b/sysdeps/x86_64/dl-tls.c
@@ -1,5 +1,5 @@
/* Thread-local storage handling in the ELF dynamic linker. x86-64 version.
- Copyright (C) 2002-2017 Free Software Foundation, Inc.
+ Copyright (C) 2017 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
@@ -16,14 +16,32 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <stdint.h>
+#ifdef SHARED
+/* Work around GCC PR58066, due to which __tls_get_addr may be called
+ with an unaligned stack. The compat implementation is in
+ tls_get_addr-compat.S. */
-/* Type used for the representation of TLS information in the GOT. */
-typedef struct dl_tls_index
+# include <dl-tls.h>
+
+/* Define __tls_get_addr within elf/dl-tls.c under a different
+ name. */
+extern __typeof__ (__tls_get_addr) __tls_get_addr_default;
+
+# define __tls_get_addr __tls_get_addr_default
+# include <elf/dl-tls.c>
+# undef __tls_get_addr
+
+hidden_ver (__tls_get_addr_default, __tls_get_addr)
+
+__attribute__ ((force_align_arg_pointer))
+void *
+__tls_get_addr (tls_index *ti)
{
- uint64_t ti_module;
- uint64_t ti_offset;
-} tls_index;
+ return __tls_get_addr_default (ti);
+}
+#else
+/* No compatibility symbol needed. */
+# include <elf/dl-tls.c>
-extern void *__tls_get_addr (tls_index *ti);
+#endif
diff --git a/sysdeps/x86_64/dl-tls.h b/sysdeps/x86_64/dl-tls.h
index 4a59d2a..c2fb56c 100644
--- a/sysdeps/x86_64/dl-tls.h
+++ b/sysdeps/x86_64/dl-tls.h
@@ -16,6 +16,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#ifndef _X86_64_DL_TLS_H
+#define _X86_64_DL_TLS_H
+
#include <stdint.h>
/* Type used for the representation of TLS information in the GOT. */
@@ -27,3 +30,5 @@ typedef struct dl_tls_index
extern void *__tls_get_addr (tls_index *ti);
+
+#endif /* _X86_64_DL_TLS_H */
-----------------------------------------------------------------------
hooks/post-receive
--
GNU C Library master sources