diff options
author | Florian Weimer <fweimer@redhat.com> | 2019-11-03 11:20:23 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2019-11-15 13:03:59 +0100 |
commit | e21a7867713c87d0b0698254685d414d811d72b2 (patch) | |
tree | 5f6a4ce16652bdd9c9f59ec9d3b5d4629104ee45 /sysdeps/generic | |
parent | e1d559f337de2c8ab68a6749dfe873477c883807 (diff) | |
download | glibc-e21a7867713c87d0b0698254685d414d811d72b2.tar.gz glibc-e21a7867713c87d0b0698254685d414d811d72b2.tar.xz glibc-e21a7867713c87d0b0698254685d414d811d72b2.zip |
Avoid zero-length array at the end of struct link_map [BZ #25097]
l_audit ends up as an internal array with _rtld_global, and GCC 10 warns about this. This commit does not change the layout of _rtld_global, so it is suitable for backporting. Future changes could allocate more of the audit state dynamically and remove it from always-allocated data structures, to optimize the common case of inactive auditing. Change-Id: Ic911100730f9124d4ea977ead8e13cee64b84d45
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/ldsodefs.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 923bd4cf36..4d67c05e72 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -379,11 +379,12 @@ struct rtld_global /* List of search directories. */ EXTERN struct r_search_path_elem *_dl_all_dirs; - /* Structure describing the dynamic linker itself. We need to - reserve memory for the data the audit libraries need. */ + /* Structure describing the dynamic linker itself. */ EXTERN struct link_map _dl_rtld_map; #ifdef SHARED - struct auditstate audit_data[DL_NNS]; + /* Used to store the audit information for the link map of the + dynamic loader. */ + struct auditstate _dl_rtld_auditstate[DL_NNS]; #endif #if defined SHARED && defined _LIBC_REENTRANT \ @@ -1178,7 +1179,15 @@ rtld_active (void) static inline struct auditstate * link_map_audit_state (struct link_map *l, size_t index) { - return &l->l_audit[index]; + if (l == &GL (dl_rtld_map)) + /* The auditstate array is stored separately. */ + return &GL (dl_rtld_auditstate) [index]; + else + { + /* The auditstate array follows the link map in memory. */ + struct auditstate *base = (struct auditstate *) (l + 1); + return &base[index]; + } } #endif /* SHARED */ |