aboutsummaryrefslogtreecommitdiff
path: root/csu/libc-tls.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2019-11-12 12:41:34 +0100
committerFlorian Weimer <fweimer@redhat.com>2019-11-12 13:54:30 +0100
commitcba932a5a9e91cffd7f4172d7e91f9b2efb1f84b (patch)
tree82fb283a15d1ff654e6b54d86008917386a03da3 /csu/libc-tls.c
parent42b926d303e571d5f9a4e97ffdb8e05d1eabae66 (diff)
downloadglibc-cba932a5a9e91cffd7f4172d7e91f9b2efb1f84b.tar
glibc-cba932a5a9e91cffd7f4172d7e91f9b2efb1f84b.tar.gz
glibc-cba932a5a9e91cffd7f4172d7e91f9b2efb1f84b.tar.bz2
glibc-cba932a5a9e91cffd7f4172d7e91f9b2efb1f84b.zip
slotinfo in struct dtv_slotinfo_list should be flexible array [BZ #25097]
GCC 10 will warn about subscribing inner length zero arrays. Use a GCC extension in csu/libc-tls.c to allocate space for the static_slotinfo variable. Adjust nptl_db so that the type description machinery does not attempt to determine the size of the flexible array member slotinfo. Change-Id: I51be146a7857186a4ede0bb40b332509487bdde8
Diffstat (limited to 'csu/libc-tls.c')
-rw-r--r--csu/libc-tls.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/csu/libc-tls.c b/csu/libc-tls.c
index 33d8b61e16..f9e5437d43 100644
--- a/csu/libc-tls.c
+++ b/csu/libc-tls.c
@@ -23,7 +23,7 @@
#include <unistd.h>
#include <stdio.h>
#include <sys/param.h>
-
+#include <array_length.h>
#ifdef SHARED
#error makefile bug, this file is for static only
@@ -32,17 +32,11 @@
dtv_t _dl_static_dtv[2 + TLS_SLOTINFO_SURPLUS];
-static struct
-{
- struct dtv_slotinfo_list si;
- /* The dtv_slotinfo_list data structure does not include the actual
- information since it is defined as an array of size zero. We define
- here the necessary entries. Note that it is not important whether
- there is padding or not since we will always access the information
- through the 'si' element. */
- struct dtv_slotinfo info[2 + TLS_SLOTINFO_SURPLUS];
-} static_slotinfo;
-
+static struct dtv_slotinfo_list static_slotinfo =
+ {
+ /* Allocate an array of 2 + TLS_SLOTINFO_SURPLUS elements. */
+ .slotinfo = { [array_length (_dl_static_dtv) - 1] = { 0 } },
+ };
/* Highest dtv index currently needed. */
size_t _dl_tls_max_dtv_idx;
@@ -72,16 +66,16 @@ TLS_INIT_HELPER
static void
init_slotinfo (void)
{
- /* Create the slotinfo list. */
- static_slotinfo.si.len = (((char *) (&static_slotinfo + 1)
- - (char *) &static_slotinfo.si.slotinfo[0])
- / sizeof static_slotinfo.si.slotinfo[0]);
- // static_slotinfo.si.next = NULL; already zero
+ /* Create the slotinfo list. Note that the type of static_slotinfo
+ has effectively a zero-length array, so we cannot use the size of
+ static_slotinfo to determine the array length. */
+ static_slotinfo.len = array_length (_dl_static_dtv);
+ /* static_slotinfo.next = NULL; -- Already zero. */
/* The slotinfo list. Will be extended by the code doing dynamic
linking. */
GL(dl_tls_max_dtv_idx) = 1;
- GL(dl_tls_dtv_slotinfo_list) = &static_slotinfo.si;
+ GL(dl_tls_dtv_slotinfo_list) = &static_slotinfo;
}
static void
@@ -205,8 +199,8 @@ __libc_setup_tls (void)
main_map->l_tls_modid = 1;
init_slotinfo ();
- // static_slotinfo.si.slotinfo[1].gen = 0; already zero
- static_slotinfo.si.slotinfo[1].map = main_map;
+ /* static_slotinfo.slotinfo[1].gen = 0; -- Already zero. */
+ static_slotinfo.slotinfo[1].map = main_map;
memsz = roundup (memsz, align ?: 1);