From 2b1dba3eb364aa65ce4ee947c39fb8d2d75e69b5 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 20 Dec 2024 15:52:57 +0100 Subject: elf: Introduce is_rtld_link_map Unconditionally define it to false for static builds. This avoids the awkward use of weak_extern for _dl_rtld_map in checks that cannot be possibly true on static builds. Reviewed-by: Adhemerval Zanella --- sysdeps/generic/ldsodefs.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'sysdeps/generic') diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 384640b734..2c25c8db46 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -1323,10 +1323,17 @@ rtld_active (void) return GLRO(dl_init_all_dirs) != NULL; } +/* Returns true of L is the link map of the dynamic linker itself. */ +static inline bool +is_rtld_link_map (const struct link_map *l) +{ + return l == &GL(dl_rtld_map); +} + static inline struct auditstate * link_map_audit_state (struct link_map *l, size_t index) { - if (l == &GL (dl_rtld_map)) + if (is_rtld_link_map (l)) /* The auditstate array is stored separately. */ return &GL (dl_rtld_auditstate) [index]; else @@ -1389,6 +1396,13 @@ void DL_ARCH_FIXUP_ATTRIBUTE _dl_audit_pltexit (struct link_map *l, attribute_hidden; #else /* !SHARED */ +/* No special dynamic linker link map in static builds. */ +static inline bool +is_rtld_link_map (const struct link_map *l) +{ + return false; +} + static inline void _dl_audit_objclose (struct link_map *l) { -- cgit v1.2.3