Re-use our roundup2() macro instead of reinventing the wheel.
Obtained from: DragonflyBSD
This commit is contained in:
parent
37a227e93c
commit
3c79e64b06
@ -33,6 +33,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
#include <sys/param.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <elf.h>
|
#include <elf.h>
|
||||||
@ -82,9 +83,6 @@ void __libc_free_tls(void *tls, size_t tcbsize, size_t tcbalign);
|
|||||||
|
|
||||||
#ifndef PIC
|
#ifndef PIC
|
||||||
|
|
||||||
#define round(size, align) \
|
|
||||||
(((size) + (align) - 1) & ~((align) - 1))
|
|
||||||
|
|
||||||
static size_t tls_static_space;
|
static size_t tls_static_space;
|
||||||
static size_t tls_init_size;
|
static size_t tls_init_size;
|
||||||
static void *tls_init;
|
static void *tls_init;
|
||||||
@ -190,7 +188,7 @@ __libc_free_tls(void *tcb, size_t tcbsize __unused, size_t tcbalign)
|
|||||||
* Figure out the size of the initial TLS block so that we can
|
* Figure out the size of the initial TLS block so that we can
|
||||||
* find stuff which ___tls_get_addr() allocated dynamically.
|
* find stuff which ___tls_get_addr() allocated dynamically.
|
||||||
*/
|
*/
|
||||||
size = round(tls_static_space, tcbalign);
|
size = roundup2(tls_static_space, tcbalign);
|
||||||
|
|
||||||
dtv = ((Elf_Addr**)tcb)[1];
|
dtv = ((Elf_Addr**)tcb)[1];
|
||||||
tlsend = (Elf_Addr) tcb;
|
tlsend = (Elf_Addr) tcb;
|
||||||
@ -210,7 +208,7 @@ __libc_allocate_tls(void *oldtls, size_t tcbsize, size_t tcbalign)
|
|||||||
Elf_Addr *dtv;
|
Elf_Addr *dtv;
|
||||||
Elf_Addr segbase, oldsegbase;
|
Elf_Addr segbase, oldsegbase;
|
||||||
|
|
||||||
size = round(tls_static_space, tcbalign);
|
size = roundup2(tls_static_space, tcbalign);
|
||||||
|
|
||||||
if (tcbsize < 2 * sizeof(Elf_Addr))
|
if (tcbsize < 2 * sizeof(Elf_Addr))
|
||||||
tcbsize = 2 * sizeof(Elf_Addr);
|
tcbsize = 2 * sizeof(Elf_Addr);
|
||||||
@ -307,7 +305,7 @@ _init_tls(void)
|
|||||||
|
|
||||||
for (i = 0; (unsigned) i < phnum; i++) {
|
for (i = 0; (unsigned) i < phnum; i++) {
|
||||||
if (phdr[i].p_type == PT_TLS) {
|
if (phdr[i].p_type == PT_TLS) {
|
||||||
tls_static_space = round(phdr[i].p_memsz,
|
tls_static_space = roundup2(phdr[i].p_memsz,
|
||||||
phdr[i].p_align);
|
phdr[i].p_align);
|
||||||
tls_init_size = phdr[i].p_filesz;
|
tls_init_size = phdr[i].p_filesz;
|
||||||
tls_init = (void*) phdr[i].p_vaddr;
|
tls_init = (void*) phdr[i].p_vaddr;
|
||||||
|
Loading…
Reference in New Issue
Block a user