diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2016-05-07 19:05:25 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2016-05-07 19:05:25 +0000 |
commit | be4e94637d7117375492627b79c41629c7da9bc3 (patch) | |
tree | 61a9fabcc07d38d2720bbb937e83103928286550 /libexec/ld.so/library_mquery.c | |
parent | 33d8693716b4a6d503e0ba97f94a783905b87f28 (diff) |
Use a Thread Information Block in both single and multi-threaded programs.
This stores errno, the cancelation flags, and related bits for each thread
and is allocated by ld.so or libc.a. This is an ABI break from 5.9-stable!
Make libpthread dlopen'able by moving the cancelation wrappers into libc
and doing locking and fork/errno handling via callbacks that libpthread
registers when it first initializes. 'errno' *must* be declared via
<errno.h> now!
Clean up libpthread's symbol exports like libc.
On powerpc, offset the TIB/TCB/TLS data from the register per the ELF spec.
Testing by various, particularly sthen@ and patrick@
ok kettenis@
Diffstat (limited to 'libexec/ld.so/library_mquery.c')
-rw-r--r-- | libexec/ld.so/library_mquery.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libexec/ld.so/library_mquery.c b/libexec/ld.so/library_mquery.c index 48151f6d4fa..870f54d7065 100644 --- a/libexec/ld.so/library_mquery.c +++ b/libexec/ld.so/library_mquery.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library_mquery.c,v 1.52 2016/03/20 02:29:51 guenther Exp $ */ +/* $OpenBSD: library_mquery.c,v 1.53 2016/05/07 19:05:23 guenther Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -108,6 +108,7 @@ _dl_tryload_shlib(const char *libname, int type, int flags) Elf_Phdr *phdp; Elf_Addr load_end = 0; Elf_Addr align = _dl_pagesz - 1, off, size; + Elf_Phdr *ptls = NULL; struct stat sb; void *prebind_data; char hbuf[4096]; @@ -205,6 +206,17 @@ _dl_tryload_shlib(const char *libname, int type, int flags) dynp = (Elf_Dyn *)phdp->p_vaddr; break; case PT_TLS: + if (phdp->p_filesz > phdp->p_memsz) { + _dl_printf("%s: invalid tls data in %s.\n", + __progname, libname); + _dl_close(libfile); + _dl_errno = DL_CANT_LOAD_OBJ; + return(0); + } + if (!_dl_tib_static_done) { + ptls = phdp; + break; + } _dl_printf("%s: unsupported TLS program header in %s\n", __progname, libname); _dl_close(libfile); @@ -309,6 +321,9 @@ retry: object->inode = sb.st_ino; object->obj_flags |= flags; _dl_set_sod(object->load_name, &object->sod); + if (ptls != NULL && ptls->p_memsz) + _dl_set_tls(object, ptls, (Elf_Addr)lowld->start, + libname); } else { _dl_load_list_free(lowld); } |