diff options
Diffstat (limited to 'elf')
-rw-r--r-- | elf/dl-close.c | 18 | ||||
-rw-r--r-- | elf/dl-conflict.c | 1 | ||||
-rw-r--r-- | elf/dl-load.c | 10 | ||||
-rw-r--r-- | elf/dl-reloc.c | 9 |
4 files changed, 25 insertions, 13 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c index b7b267e2bf..7655ef433e 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -53,18 +53,22 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp) else { struct link_map *old_map = listp->slotinfo[idx - disp].map; - assert (old_map != NULL); - /* Mark the entry as unused. */ - listp->slotinfo[idx - disp].gen = GL(dl_tls_generation) + 1; - listp->slotinfo[idx - disp].map = NULL; + /* The entry might still be in its unused state if we are closing an + object that wasn't fully set up. */ + if (__builtin_expect (old_map != NULL, 1)) + { + assert (old_map->l_tls_modid == idx); + + /* Mark the entry as unused. */ + listp->slotinfo[idx - disp].gen = GL(dl_tls_generation) + 1; + listp->slotinfo[idx - disp].map = NULL; + } /* If this is not the last currently used entry no need to look further. */ - if (old_map->l_tls_modid != GL(dl_tls_max_dtv_idx)) + if (idx != GL(dl_tls_max_dtv_idx)) return true; - - assert (old_map->l_tls_modid == GL(dl_tls_max_dtv_idx)); } while (idx - disp > disp == 0 ? 1 + GL(dl_tls_static_nelem) : 0) diff --git a/elf/dl-conflict.c b/elf/dl-conflict.c index e38deee9de..ae091abd27 100644 --- a/elf/dl-conflict.c +++ b/elf/dl-conflict.c @@ -44,6 +44,7 @@ _dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict, /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */ #define RESOLVE_MAP(ref, version, flags) (*ref = NULL, NULL) #define RESOLVE(ref, version, flags) (*ref = NULL, 0) +#define CHECK_STATIC_TLS(ref_map, sym_map) ((void) 0) #define RESOLVE_CONFLICT_FIND_MAP(map, r_offset) \ do { \ while ((resolve_conflict_map->l_map_end < (ElfW(Addr)) (r_offset)) \ diff --git a/elf/dl-load.c b/elf/dl-load.c index db9391ea66..2f2a9be566 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -957,7 +957,9 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, #else /* Uh-oh, the binary expects TLS support but we cannot provide it. */ - _dl_fatal_printf ("cannot handle file '%s' with TLS data\n", name); + errval = 0; + errstring = N_("cannot handle TLS data"); + goto call_lose; #endif break; } @@ -1173,11 +1175,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, /* Make sure we are not dlopen'ing an object that has the DF_1_NOOPEN flag set. */ - if ((__builtin_expect (l->l_flags_1 & DF_1_NOOPEN, 0) -#ifdef USE_TLS - || __builtin_expect (l->l_flags & DF_STATIC_TLS, 0) -#endif - ) + if (__builtin_expect (l->l_flags_1 & DF_1_NOOPEN, 0) && (mode & __RTLD_DLOPEN)) { /* We are not supposed to load this object. Free all resources. */ diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index 37d1ee019f..d6db62b11e 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -159,6 +159,15 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], l->l_lookup_cache.value = _lr; })) \ : l->l_addr) +#define CHECK_STATIC_TLS(map, sym_map) \ + do { \ + if (__builtin_expect ((sym_map)->l_tls_offset == 0, 0)) \ + { \ + errstring = N_("shared object cannot be dlopen()ed"); \ + INTUSE(_dl_signal_error) (0, (map)->l_name, NULL, errstring); \ + } \ + } while (0) + #include "dynamic-link.h" ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling); |