diff options
| author | Florian Weimer <fweimer@redhat.com> | 2024-12-20 15:52:57 +0100 |
|---|---|---|
| committer | Florian Weimer <fweimer@redhat.com> | 2024-12-20 15:52:57 +0100 |
| commit | 2b1dba3eb364aa65ce4ee947c39fb8d2d75e69b5 (patch) | |
| tree | 0036fd9611c8a9cda941c72ef80d16201380e24d /elf | |
| parent | 322e9d4e443084336ea41a8e7bf72456ab273b73 (diff) | |
| download | glibc-2b1dba3eb364aa65ce4ee947c39fb8d2d75e69b5.tar.xz glibc-2b1dba3eb364aa65ce4ee947c39fb8d2d75e69b5.zip | |
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 <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf')
| -rw-r--r-- | elf/dl-dst.h | 7 | ||||
| -rw-r--r-- | elf/do-rel.h | 11 | ||||
| -rw-r--r-- | elf/dynamic-link.h | 2 | ||||
| -rw-r--r-- | elf/rtld.c | 2 |
4 files changed, 4 insertions, 18 deletions
diff --git a/elf/dl-dst.h b/elf/dl-dst.h index 07100e5ff9..bff3685b83 100644 --- a/elf/dl-dst.h +++ b/elf/dl-dst.h @@ -18,11 +18,6 @@ #include "trusted-dirs.h" -#ifdef SHARED -# define IS_RTLD(l) (l) == &GL(dl_rtld_map) -#else -# define IS_RTLD(l) 0 -#endif /* Guess from the number of DSTs the length of the result string. */ #define DL_DST_REQUIRED(l, name, len, cnt) \ ({ \ @@ -44,7 +39,7 @@ auditing, in ld.so. */ \ if ((l)->l_origin == NULL) \ { \ - assert ((l)->l_name[0] == '\0' || IS_RTLD (l)); \ + assert ((l)->l_name[0] == '\0' || is_rtld_link_map (l)); \ (l)->l_origin = _dl_get_origin (); \ dst_len = ((l)->l_origin && (l)->l_origin != (char *) -1 \ ? strlen ((l)->l_origin) : 0); \ diff --git a/elf/do-rel.h b/elf/do-rel.h index afea61cfd2..f9841966d5 100644 --- a/elf/do-rel.h +++ b/elf/do-rel.h @@ -102,16 +102,7 @@ elf_dynamic_do_Rel (struct link_map *map, struct r_scope_elem *scope[], else #endif { - /* This is defined in rtld.c, but nowhere in the static libc.a; make - the reference weak so static programs can still link. This - declaration cannot be done when compiling rtld.c (i.e. #ifdef - RTLD_BOOTSTRAP) because rtld.c contains the common defn for - _dl_rtld_map, which is incompatible with a weak decl in the same - file. */ -# ifndef SHARED - weak_extern (GL(dl_rtld_map)); -# endif - if (map != &GL(dl_rtld_map)) /* Already done in rtld itself. */ + if (!is_rtld_link_map (map)) /* Already done in rtld itself. */ # if !defined DO_RELA || defined ELF_MACHINE_REL_RELATIVE /* Rela platforms get the offset from r_addend and this must be copied in the relocation address. Therefore we can skip diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h index 370b0e872e..7649ea89e5 100644 --- a/elf/dynamic-link.h +++ b/elf/dynamic-link.h @@ -192,7 +192,7 @@ elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[], do { \ int edr_lazy = elf_machine_runtime_setup ((map), (scope), (lazy), \ (consider_profile)); \ - if (((map) != &GL(dl_rtld_map) || DO_RTLD_BOOTSTRAP)) \ + if (!is_rtld_link_map (map) || DO_RTLD_BOOTSTRAP) \ ELF_DYNAMIC_DO_RELR (map); \ ELF_DYNAMIC_DO_REL ((map), (scope), edr_lazy, skip_ifunc); \ ELF_DYNAMIC_DO_RELA ((map), (scope), edr_lazy, skip_ifunc); \ diff --git a/elf/rtld.c b/elf/rtld.c index b8cc3f605f..44bcf29ff6 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -1960,7 +1960,7 @@ dl_main (const ElfW(Phdr) *phdr, GL(dl_rtld_map).l_next->l_prev = GL(dl_rtld_map).l_prev; for (i = 1; i < main_map->l_searchlist.r_nlist; ++i) - if (main_map->l_searchlist.r_list[i] == &GL(dl_rtld_map)) + if (is_rtld_link_map (main_map->l_searchlist.r_list[i])) break; /* Insert the link map for the dynamic loader into the chain in |
